kotlinx.serialization icon indicating copy to clipboard operation
kotlinx.serialization copied to clipboard

Add ability to disallow repeated keys in CBOR

Open timmc opened this issue 1 year ago • 0 comments

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.readElement to handle maps
  • CborReader.decodeElementIndex to 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.

timmc avatar May 20 '24 01:05 timmc