Scala Jackson解组-属性“ config”的设置器定义冲突:com.fasterxml.jackson.databind.ObjectMapper#setConfig(1 params)与

时间:2018-06-20 02:12:15

标签: json scala jackson

我有一个小的Scala程序,用于解组JSON,但收到错误:“ com.fasterxml.jackson.databind.JsonMappingException:属性“ config”的setter定义冲突:com.fasterxml.jackson.databind.ObjectMapper#setConfig(1参数)vs com.fasterxml.jackson.databind.ObjectMapper#setConfig(1个参数) “

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper

object JsonUtil {
  val sampleJson =
    """{
                         "operator" : ">",
                         "displayName" : "Months Since Start",
                         "fieldName" : "months_since_start",
                         "fieldType" : "double",
                         "expression" : "12"
                     }"""


  case class Rules(operator: String,
                   displayName: String,
                   fieldName: String,
                   fieldType: String,
                   expression: String)

  val mapper = new ObjectMapper() with ScalaObjectMapper
  mapper.registerModule(DefaultScalaModule)
  mapper.readValue(sampleJson, classOf[Rules])


}

我在这里做错了什么?我使用Scala scalaVersion:=“ 2.11.11”

0 个答案:

没有答案