Details
-
Improvement
-
Resolution: Cannot Reproduce
-
Major - P3
-
None
-
None
-
None
Description
This is from golang std json:
The "omitempty" option specifies that the field should be omitted from the encoding if the field has an empty value, defined as false, 0, a nil pointer, a nil interface value, and any empty array, slice, map, or string.
|
bson "omitempty" tag should do the same behavior as json so that we could reduce the number of pointers in decoding struct types.
Example:
struct below
type xyz struct {
|
Test string `bson:"test,omitempty"`
|
}
|
won't work with this "bson" data:
{"test":null}
|
but will work fine with golang std json: https://play.golang.org/p/q-Wnr81Pu3b