▲ | gethly 3 days ago | ||||||||||||||||
This V2 is still pushing forward the retarded behavior from v1 when it comes to handling nil for maps, slices and pointers. I am so sick and tired of this crap. I had to fork the v1 to make it behave properly and they still manage to fuck up completely new version just as well(by pushing omitempty and ignoring omitnil behavior as a standalone case) which means I will be stuck with the snale-pace slow v1 for ever. | |||||||||||||||||
▲ | adamrt 3 days ago | parent | next [-] | ||||||||||||||||
Are you sure about that? Unless I'm misunderstanding they did fix this: https://pkg.go.dev/encoding/json "In v1, a nil Go slice or Go map is marshaled as a JSON null. In contrast, v2 marshals a nil Go slice or Go map as an empty JSON array or JSON object, respectively. The jsonv2.FormatNilSliceAsNull and jsonv2.FormatNilMapAsNull options control this behavior difference. To explicitly specify a Go struct field to use a particular representation for nil, either the `format:emitempty` or `format:emitnull` field option can be specified. Field-specified options take precedence over caller-specified options." | |||||||||||||||||
▲ | ycombinatrix 3 days ago | parent | prev | next [-] | ||||||||||||||||
What is your preferred behavior for a nil map/slice? Feels weird that it doesn't map to null. | |||||||||||||||||
| |||||||||||||||||
▲ | Mogzol 3 days ago | parent | prev | next [-] | ||||||||||||||||
Isn't that what the new 'omitzero' option is for? https://pkg.go.dev/github.com/go-json-experiment/json#exampl... | |||||||||||||||||
▲ | kanbara 2 days ago | parent | prev [-] | ||||||||||||||||
you know you can make your case better if you don’t use disrespectful and offensive language |