CBOR untaggedNullValueTags configuration option (#2966) - #3074
CBOR untaggedNullValueTags configuration option (#2966)#3074travishaagen wants to merge 2 commits into
Conversation
|
@fzhinkin Hello! Thanks for taking a look. How can I help move this forward? |
|
The change makes sense. I would only consider a different name for configuration option: all binary flags use a verb in their name, and I don't see why should we make an exception here. Perhaps, Note that configuration options tend to get a companion-annotation to allow a more fine-grained control over behavior. And while an annotation was not proposed here yet (and I would definitely like to postpone its introduction until it is really necessary), it's worth thinking about how the annotation would look like / what name it would have, to use a coherent option name here. One option here would be just adding an additional boolean parameter to |
Introduces a new CBOR configuration option called
untaggedNullValueTags. When enabled, CBOR value-tags will not be serialized fornullvalues, and deserialization will not fail validation. This is allowed by the CBOR spec as mentioned in this issue.When
untaggedNullValueTags=true, the encoding for the provided unit test is https://cbor.me/?bytes=bf6161a0d8226162f6d8386163f66164f6ff where the tags shown below are key-tags,For comparison, when
untaggedNullValueTags=false, the encoding is https://cbor.me/?bytes=bf6161cca0d8226162f6d8386163d84ef66164d85accf6ffNote however, that Kotlinx Serialization cannot currently deserialize the above anyhow.
This change is needed for a real world use-case, where "untagged
nullvalues" are a requirement for value-tags. Thank you!