Commit Graph

2 Commits

Author SHA1 Message Date
Ben Luddy
ba129ebd42
Add optional support for json.Unmarshaler.
Users can provide a function to transcode an encoded CBOR data item to JSON. If provided, then
unmarshaling into a value whose type implements json.Unmarshaler, but not cbor.Unmarshaler, will
first transcode the input bytes to JSON and then invoke UnmarshalJSON on the destination value.

Signed-off-by: Ben Luddy <bluddy@redhat.com>
2025-06-17 10:45:07 -04:00
Ben Luddy
d8e0aa63e6
Add optional encoding support for json.Marshaler.
If the user provides a JSON-to-CBOR transcode function, a value whose type implements json.Marshaler
and not cbor.Marshaler will be encoded by first calling its MarshalJSON method, then transcoding the
result to CBOR.

Signed-off-by: Ben Luddy <bluddy@redhat.com>
2025-06-17 10:44:47 -04:00