Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
proposal: encoding/json: struct tag to marshal nil slices and maps as non-null #27589
There have been many reports about encoding a nil slice or map as
Currently it is encoded as
It would be nice if a struct tag can be used to signify that we intend the nil slice or map to be treated as an empty slice or map respectively for the purposes of marshalling.
Current solutions include: https://github.com/helloeave/json. This is not a nice solution because it requires the assistance of a third-party package.
This is how it's implemented in third party lib: helloeave/json@7b6e442
changed the title from
Feature request: Struct tag for json to marshall null slices/maps as non-nil
proposal: encoding/json: struct tag to marshal nil slices and maps as non-null
Sep 10, 2018
referenced this issue
Sep 22, 2018
If it was called
I then went from that step to
Perhaps due to the confusion, and ambiguity,
The "JSON sweep" is a sweep through all the JSON proposal trying to come up with a comprehensive yay/nay to each proposal in an effort to balance features desired with not adding too much technical debt.