encoding/json: clarify what happens when multiple items match the same field #43664
Labels
Milestone
Comments
I'm well aware of this problem, unfortunately. See #14750, which this issue is likely a duplicate of. My attempt at fixing this without incurring a performance or memory cost is https://go-review.googlesource.com/c/go/+/224079, which has been stuck in review limbo for a little while :) |
At the core of this problem is whether we want to favor a streaming decode or whether we want to buffer all the members of a JSON object in order to perform an exact match. The former has significantly better performance, while the latter probably matches user expectation better. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This test I added to encoding/json
prints
The comment says Unmarshal "prefers" exact matches, but if there are no words about what happens if multiple fields match.
It's clearly an odd case, but clarity would be nice. I expected the exact match to win always.
The text was updated successfully, but these errors were encountered: