add SetJSONLastValueWins allowing JSON unmarshal to error on duplicate instead of last-value-wins#35
add SetJSONLastValueWins allowing JSON unmarshal to error on duplicate instead of last-value-wins#35zamicol wants to merge 1 commit intoiancoleman:masterfrom
Conversation
…e instead of last-value-wins
|
Thanks for this, looks good. The reason and benefit for this PR is clear (thanks for the excellent comments in the code). The main hesitation I have with this is surprising behavior compared to the standard One of the goals is for b := []byte(`{"x":1,"x":2}`)
// normal map behavior
m := map[string]int{}
err := json.Unmarshal(b, &m) // no error
// ordered map behavior
o := New()
err = json.Unmarshal(b, &o) // no error, but would have error if this PR is mergedI tried to see if json v2 in https://github.com/go-json-experiment/json was likely to be incorporated into golang standard libraries but couldn't find any info about it. I'm not sure if deviating from the standard map is desired at this time. Is there some more info about 'the planned revision' in the comment "Until Go releases the planned revision to the JSON package"? Is this planned to be added to One alternative option might be changing |
|
For a drop-in replacement, I believe the easy fix is to flip the default value of
Yes, the Go team has acknowledge that there are many concerns with the existing implementation of JSON, and that it's deserving of a revision. mvdan has confirmed this, and was more explicit on a personal email. The abstract "JSONv2" will include many changes from the existing implementation but there's no firm plans to get this done any time soon. Edit: Looks like Go is planning on For other JSON problems, this is a good link: https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+encoding%2Fjson+in%3Atitle |
No description provided.