Documentation ¶
Overview ¶
Example ¶
package main import ( "github.com/mnhkahn/gogogo/logger" "github.com/mnhkahn/jsonfield" ) type A struct { A int B int } func main() { jj := new(A) jj.A, jj.B = 111, 222 buf, _ := jsonfield.Marshal(jj) logger.Info(string(buf)) // prints {"A":111,"B":222} buf, _ = jsonfield.Marshal(jj, "A") logger.Info(string(buf)) // prints {"A":111} }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal is compatible with std json.Marshal. If fields is nil it acts as the std json package. If fields is not nil it will only return the provided fields.
Example ¶
package main import ( "github.com/mnhkahn/jsonfield" ) type A struct { A int B int } func main() { jj := new(A) jj.A, jj.B = 111, 222 byts, err := jsonfield.Marshal(jj, "A") // {"A":111} _, _ = byts, err }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.