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

Comments

@mvdan
Copy link
Member

@mvdan 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants