How do I marshal a struct field as an empty json object? For example,
type Person struct {
Name string `json:"name"`
Meta map[string]interface{} `json:"meta"`
}
When I marshal this struct to JSON, I would like to keep the "meta" field
as empty json object, like "{}", if it is an empty map, instead of null or
being omitted (using omitempty).
{
"name" : "tester",
"meta": {}
}
Here is the quick sample in playground: http://play.golang.org/p/VRtnY8Ww2s
Thanks!
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.