Closed
Description
by krolaw:
Both packages define empty as being: "The empty values are false, 0, any nil pointer or interface value, and any array, slice, map, or string of length zero." However, json does not look at the value behind pointers, while xml does. This difference is made obvious when wanting to omit nil pointers, but retain empty values. Without omitempty: xml will omit tags with nil pointers (not documented) json will display null for nil pointers. With omitempty: xml will omit pointer fields pointing to empty values. json will DISPLAY pointer fields pointing to empty values. My current solution is: have omitempty on for json and off for xml. http://play.golang.org/p/hANosIIkM_ This is probably a documentation issue. If it's a bug, please retain ability to omit nil pointers, but not look at values beyond the pointer. Thanks.