cbor
cbor copied to clipboard
feature: Encode nil map/slice with cbor empty map/list tag
Is your feature request related to a problem? Please describe. I use cbor as a serialization format for rpc between services written in different languages. So when i try to send some structure like
type Example struct {
Data map[string]string `cbor:"data"`
}
I always need to initialize Data explicitly Example{Data: map[string]string{}} because Example{} is serialized to {"data":null}.
So I need to describe this dto in python like
class Example:
data: Optional[dict[str, str]]
despite the fact that this field is required.
Describe the solution you'd like I think it would be nice to have encoding option to enforce encoder use empty list/map cbor type for nil slice/map.
@dedefer Thanks for opening issue and PR. It makes sense to me to add this option.
I'll take a look at the PR. It may be a while because I need to update fuzz test, etc. first.
@fxamacker Could you please give any updates on an issue?
Hello @dedefer,
I like your PR and want to include it in the next release. I've been swamped with work and hope to get to it after an upcoming deadline. I need to update the fuzzer for this PR and etc. so there's some extra work behind the scenes.
You can specify unmerged PR's commit inside go.mod as a workaround before the PR is merged.
Thanks again for the contribution and your patience!
It's ok! I know that feel, bro. Thanks for not forgetting about this issue! I really appreciate your work!
Closed by PR #352 and #377.