-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
json: marshal nil slice as null
#2278
Labels
Comments
Comment 5 by [email protected]: Unless "nil" byte slice is encoded as JSON "null", it is impossible to distinguish between missing value and empty string/slice when serializing byte slice fields. Also, the current behavior is inconsistent: Suppose we have a JSON object X = {"foo": null}. If we apply json.Marshal(json.Unmarshal(X)), the current implementation will produce {"foo": ""}. Oops! I ran into this issue when using json.Marshal on goprotobuf-genereated types. Goprotobuf consistently treats "nil" as missing field, while as json.Marshal generates empty string from it. |
Owner changed to @rsc. Status changed to Accepted. |
This issue was closed by revision 48c75c5. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by awreece:
Attachments:
The text was updated successfully, but these errors were encountered: