All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.dev.evo.elasticmagic.serde.jackson.YamlDeserializer.kt Maven / Gradle / Ivy

package dev.evo.elasticmagic.serde.jackson

import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper

import dev.evo.elasticmagic.serde.Deserializer
import dev.evo.elasticmagic.serde.StdDeserializer

object YamlDeserializer : StdDeserializer() {
    private val mapper = YAMLMapper()
    private val typeRef = object : TypeReference>() {}

    override fun objFromStringOrNull(data: String): Deserializer.ObjectCtx? {
        return try {
            ObjectCtx(mapper.readValue(data, typeRef))
        } catch (ex: JsonProcessingException) {
            null
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy