Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add option to ignore unrecognized tags when unmarshaling into interface{} #470

Closed
ssuriyan7 opened this issue Jan 16, 2024 · 2 comments

Comments

@ssuriyan7
Copy link
Contributor

Is your feature request related to a problem? Please describe.
When unmarshaling a CBOR item into a Go interface{} value, and the item has an unrecognized tag number, the concrete object stored in the interface{} value is a cbor.Tag{} struct. In our project, there is a need to unmarshal CBOR into map[string]interface{} so that it can be used in places currently using encoding/json. The existing code that unmarshals JSON into map[string]interface{} and processes it, expects to deal with concrete values of certain types (bool, float64, string, []interface{}, map[string]interface{}, or nil). To achieve compatibility with the current code that uses encoding/json, there's a need to configure cbor's decode operation so that when it decodes an unrecognized tag into interface{}, it ignores the tag.

Describe the solution you'd like
Add a new decode option to make the behavior of ignoring unrecognized tags when unmarshaling into interface{} configurable. The option would allow compatibility with existing code that assumes decoding into interface{} produces something compatible with the encoding/json behavior.

Additional context
I'd be happy to contribute the changes needed for this issue.

@fxamacker
Copy link
Owner

@ssuriyan7 Thanks for opening this issue! Please feel free to open a PR to add new decoding option for this!

@fxamacker
Copy link
Owner

Closed by #475.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants