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

proposal: encoding/json: add decoder option to reject duplicate fields #59414

Closed
sding3 opened this issue Apr 4, 2023 · 3 comments
Closed

proposal: encoding/json: add decoder option to reject duplicate fields #59414

sding3 opened this issue Apr 4, 2023 · 3 comments

Comments

@sding3
Copy link
Contributor

sding3 commented Apr 4, 2023

Add encoding/json.Decoder.DisallowDuplicateFields() to let decoding of JSON object containing duplicate fields to error out.

When JSON object contain duplicates, it is often result of human error. So it would be good for the standard library to provide an easy way to configure the decoder to allow detecting such user errors.

@sding3 sding3 added the Proposal label Apr 4, 2023
@gopherbot gopherbot added this to the Proposal milestone Apr 4, 2023
@sding3 sding3 changed the title proposal: encoding/json: reject duplicate fields proposal: encoding/json: add decoder option to reject duplicate fields Apr 4, 2023
@sding3
Copy link
Contributor Author

sding3 commented Apr 4, 2023

I see there is #14750. If there is a resolution to be implemented for that, this new encoding/json.Decoder.DisallowDuplicateFields() should consider case sensitivity as configured on the decoder.

@ianlancetaylor
Copy link
Contributor

CC @dsnet @mvdan

@dsnet
Copy link
Member

dsnet commented Apr 4, 2023

Duplicate of #48298. I haven't implemented it as I've been focusing on larger scale changes to the entire package.

@dsnet dsnet closed this as completed Apr 4, 2023
@golang golang locked and limited conversation to collaborators Apr 3, 2024
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

4 participants