Skip to content
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 should sanity-check tags #1520

Closed
robpike opened this issue Feb 16, 2011 · 3 comments
Closed

JSON should sanity-check tags #1520

robpike opened this issue Feb 16, 2011 · 3 comments

Comments

@robpike
Copy link
Contributor

robpike commented Feb 16, 2011

The JSON package uses structure tags to allow the user to define names for the JSON
fields that differ from those in the Go struct.  The protocol buffer uses tags for a
different purpose.  If one wants to use JSON to marshal a value achieved from a protocol
buffer, things go south; one gets badly formed names.

The protocol buffer code introduced the format "PB(...)" for its tags.  We
could extend that convention with JSON, saying (perhaps) that "JSON(XXX)" is
the way to define a renaming.

In any case, JSON should certainly not use a tag that isn't an identifier.  This would
be a simple step that avoids the most obvious collision.
@gopherbot
Copy link

Comment 1 by cw@f00f.org:

Small note:
Right now I have JSON performance issues that could be further exacerbated by making the
tags even more complex.

@robpike
Copy link
Contributor Author

robpike commented Feb 17, 2011

Comment 2:

They don't need to be more complex.  All I'm asking, at least for now, is a sanity
check, which should be very cheap.
JSON's implementation could be smarter, too. It's heavily reflection-driven but there
are ways to do better if it becomes important.

@rsc
Copy link
Contributor

rsc commented Feb 17, 2011

Comment 3:

This issue was closed by revision f80d002.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants