-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for omitnil #53
Comments
I think this is related to golang/go#45669 |
I suspect that your use-case is already satisfied by the |
Technically it solves my issue but only on struct tag basis. I want a global configuration targeting only nils specifically, not all zero values. |
#61 adds a caller-specified option to omit all zero struct fields. |
global omitzero will get rid of false or 0, i don't know how else to communicate i want to get rid of null values in json, not default values in Go. i'll stick with my forked native json because this brings no value to me. cheers. |
I have been fighting Go's json for years when it comes to handling of null values.
Go's implementation only has
omitempty
and it treats{}
,[]
andnull
as one and the same. But{}
and[]
are information of intent whereasnull
is not. I have been handling this issue in various ways and presently I am using a fork of native json library, after years of using Goccy and clean-up code that stripped null values from raw json. This was still more performant than using native json. Sadly the entire standard library lacks in performance, after a decade of neglect. But goccy has been lagging with issues and I no longer trust it, hence the fork.In short, please add configuration option to not render null values. Also add
omitnil
oromitnull
tag, so we can target maps and slices individually when we want to distinguish nil and empty values, since maps and slices are pointers in Go.The text was updated successfully, but these errors were encountered: