kotlinx.serialization
kotlinx.serialization copied to clipboard
Add ability to disallow repeated keys in CBOR
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2662 by adding a visitKey method to CompositeDecoder; map and set serializers should call this so that decoders have an opportunity to throw an error when a duplicate key is detected. Calls to this method are added to:
MapLikeSerializer.readElementto handle mapsCborReader.decodeElementIndexto handle data classes
A new config option Cbor.forbidDuplicateKeys can be set to true to enable this new behavior. This can form the basis of a Strict Mode in the future.