JacksonCodec

class JacksonCodec<T : Any>(val name: String, val mapper: ObjectMapper, val sourceClass: KClass<T>) : Codec<T, ByteArray> (source)

ByteArrayCodec implementation that delegates JSON processing to a Jackson ObjectMapper.

Parameters

T

domain type handled by the codec.

Constructors

Link copied to clipboard
constructor(name: String, mapper: ObjectMapper, sourceClass: KClass<T>)

Properties

Link copied to clipboard
val mapper: ObjectMapper

Jackson mapper used for serialization and deserialization.

Link copied to clipboard

human-readable identifier used when reporting failures.

Link copied to clipboard
open override val sourceClass: KClass<T>

runtime KClass representing the decoded type.

Link copied to clipboard
open override val targetClass: KClass<ByteArray>

Runtime KClass representing the byte array payload produced by encode.

Functions

Link copied to clipboard
open override fun decode(input: ByteArray): EitherNel<String, T>

Attempts to decode the provided input using the configured Jackson mapper.

Link copied to clipboard
open override fun encode(input: T): ByteArray

Encodes the given input into a JSON ByteArray using the configured Jackson mapper.