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

encoding/json: document and test composing multiple field tag options #47498

Open
mvdan opened this issue Aug 2, 2021 · 0 comments
Open

encoding/json: document and test composing multiple field tag options #47498

mvdan opened this issue Aug 2, 2021 · 0 comments
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Aug 2, 2021

It seems like encoding/json allows using multiple field tag options at once, such as ,omitempty and ,string:

https://play.golang.org/p/382n_YPRJ_4

This does not appear to be documented or tested in the json package. We should probably do that.

It's also worth thinking if there's any combination of options that would interact in confusing ways. In that case, the docs might need to document what their combined behavior would be, e.g. in what order the options take effect.

One particular example is ,omitempty and ,string, which is easy, given that the only way omitempty makes sense in that combination is if it applies before string when encoding.

cc @dsnet

@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 2, 2021
@cagedmantis cagedmantis added this to the Unplanned milestone Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants