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: Option to disable built-in support for BinaryMarshaler and BinaryUnmarshaler #525

Closed
benluddy opened this issue Apr 25, 2024 · 2 comments

Comments

@benluddy
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I'm introducing CBOR as an alternative to an existing JSON codec based on the stdlib encoding/json package, whose marshal and unmarshal behaviors are not at all affected by whether or not a value's type implements BinaryMarshaler or BinaryUnmarshaler. Users can today be successfully encoding and decoding types that implement these interfaces to and from JSON. If they flip the switch to instead use CBOR, today, CBOR may produce or expect something entirely different in structure and content from the current JSON.

Describe the solution you'd like

Encode and Decode options to ignore BinaryUnmarshaler and BinaryMarshaler on decode and encode.

Describe alternatives you've considered

This is a built-in behavior, so I don't think it can be disabled through an existing extension point. Over time, I hope efforts like #507 will make it possible both for users to set custom marshal/unmarshal behaviors on interface types that they do not control, and that the BinaryMarshaler built-in could be implemented with (and configurable by) the same mechanism.

Additional context

@benluddy
Copy link
Contributor Author

I implemented what I am proposing in #526.

@fxamacker
Copy link
Owner

Thanks Ben! 🎉 Closed by #526.

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