You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'm working on a project that serves and persists API resources in a JSON encoding. The existing JSON encoding is case-sensitive in matching JSON object keys to struct field names during decode. I would like to support CBOR as an alternative encoding with case-sensitive field matching.
Describe the solution you'd like
A new DecOption field that can disable fallback to case-insensitive field matching. The default would preserve the current behavior.
Additional context
It's particularly interesting when an input map has multiple case variations on a field tag. For example, if you're unmarshaling into:
struct {
Foo string `json:"bar"`
}
The first matching key in the map wins. So "\xa2\x63bar\x65lower\x63BAR\x65UPPER" gives you "lower" and "\xa2\x63BAR\x65UPPER\x63bar\x65lower" gives you "UPPER". You can catch this if unknown field errors are enabled, but the map key that appears in the error also depends on where it appears in the input.
I'm happy to open a PR myself if you think this is a feature you'd accept.
The text was updated successfully, but these errors were encountered:
Hey @benluddy, I can review your PR this weekend (probably Sunday) if it is available.
If you haven't started yet, I can try to implement this feature over the weekend and add it to next milestone for release.
Currently, this library and Go's encoding/json package use variants of case-insensitive field name matching, but I really like your suggestion! Thanks for opening this issue with details needed to make it easy to accept your suggestion! 👍
Is your feature request related to a problem? Please describe.
I'm working on a project that serves and persists API resources in a JSON encoding. The existing JSON encoding is case-sensitive in matching JSON object keys to struct field names during decode. I would like to support CBOR as an alternative encoding with case-sensitive field matching.
Describe the solution you'd like
A new DecOption field that can disable fallback to case-insensitive field matching. The default would preserve the current behavior.
Additional context
It's particularly interesting when an input map has multiple case variations on a field tag. For example, if you're unmarshaling into:
The first matching key in the map wins. So "\xa2\x63bar\x65lower\x63BAR\x65UPPER" gives you "lower" and "\xa2\x63BAR\x65UPPER\x63bar\x65lower" gives you "UPPER". You can catch this if unknown field errors are enabled, but the map key that appears in the error also depends on where it appears in the input.
I'm happy to open a PR myself if you think this is a feature you'd accept.
The text was updated successfully, but these errors were encountered: