It's also less error prone, as the decoder cannot be reused.
Technically this is a breaking change, since the DisallowUnknownFields might by passed as a function pointer, although I cannot imagine any use for that. Alternatively, We could add a Strict method to the decoder, to avoid breaking existing code.
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
proposal: add *json.Decoder to return type of DisallowUnknownFields
proposal: encoding/json: add *json.Decoder to return type of DisallowUnknownFields
Aug 7, 2020
We can agree or disagree as to whether this would be a good idea, but it doesn't matter because we can't make this change. It would break the Go 1 compatibility guarantee (https://golang.org/doc/go1compat). Sorry.
For strict json parsing using encoding/json, one has to write the following quite often:
Instead, being able to chain these calls makes the API more pleasant to use:
It's also less error prone, as the decoder cannot be reused.
Technically this is a breaking change, since the DisallowUnknownFields might by passed as a function pointer, although I cannot imagine any use for that. Alternatively, We could add a
Strict
method to the decoder, to avoid breaking existing code.The text was updated successfully, but these errors were encountered: