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

com.sksamuel.elastic4s.jackson.JacksonSupport.scala Maven / Gradle / Ivy

There is a newer version: 8.11.5
Show newest version
package com.sksamuel.elastic4s.jackson

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.databind.ser.std.NumberSerializers
import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper}
import com.fasterxml.jackson.module.scala.{ClassTagExtensions, DefaultScalaModule}
import com.sksamuel.elastic4s.requests.searches.Total

object JacksonSupport {

  val mapper: ObjectMapper with ClassTagExtensions = new ObjectMapper with ClassTagExtensions
  mapper.registerModule(DefaultScalaModule)

  mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
  mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
  mapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false)
  mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true)
  mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
  mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)

  val module = new SimpleModule {
    addSerializer(new NumberSerializers.DoubleSerializer(classOf[Double]))
//    addDeserializer(classOf[Total], new Total.Deserializer(classOf[Total]))
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy