Class KotlinSerializationCborHttpMessageConverter

All Implemented Interfaces:
HttpMessageConverter<Object>, SmartHttpMessageConverter<Object>

public class KotlinSerializationCborHttpMessageConverter extends KotlinSerializationBinaryHttpMessageConverter<kotlinx.serialization.cbor.Cbor>
Implementation of HttpMessageConverter that can read and write CBOR using kotlinx.serialization. It supports application/cbor.

As of Spring Framework 7.0, by default it only types annotated with @Serializable at type or generics level since it allows combined usage with other general purpose JSON decoders like JacksonCborHttpMessageConverter without conflicts.

Alternative constructors with a Predicate<ResolvableType> parameter can be used to customize this behavior. For example, new KotlinSerializationCborHttpMessageConverter(type -> true) will decode all types supported by Kotlin Serialization, including unannotated Kotlin enumerations, numbers, characters, booleans and strings.

Since:
6.0
Author:
Iain Henderson, Sebastien Deleuze
  • Constructor Details

    • KotlinSerializationCborHttpMessageConverter

      public KotlinSerializationCborHttpMessageConverter()
      Construct a new converter using Cbor.Default instance which only converts types annotated with @Serializable at type or generics level.
    • KotlinSerializationCborHttpMessageConverter

      public KotlinSerializationCborHttpMessageConverter(Predicate<ResolvableType> typePredicate)
      Construct a new converter using Cbor.Default instance which only converts types for which the specified predicate returns true.
      Since:
      7.0
    • KotlinSerializationCborHttpMessageConverter

      public KotlinSerializationCborHttpMessageConverter(kotlinx.serialization.cbor.Cbor cbor)
      Construct a new converter using the provided Cbor instance which only converts types annotated with @Serializable at type or generics level.
    • KotlinSerializationCborHttpMessageConverter

      public KotlinSerializationCborHttpMessageConverter(kotlinx.serialization.cbor.Cbor cbor, Predicate<ResolvableType> typePredicate)
      Construct a new converter using the provided Cbor instance which only converts types for which the specified predicate returns true.
      Since:
      7.0