fix: json union unmarshal to consider other union variants #5758
+11
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My first attempt at closing #3474
unmarshal_object
to return an error if no field at all was parsed / assigned to the structunmarshal_value
to iterate over the remaining union variants until one succeeds or runs out of variants:Odin/core/encoding/json/unmarshal.odin
Lines 277 to 290 in 7237747
Open questions / not considered yet:
b
json key while trying to parse theA
struct. Not sure if this is true for the general caseAnyone feel free to pick this up, I'm just getting started with odin and there might be better ways to solve this issue 🙂
Reproduction example that is fixed with this change