使用Circe JsonKey时无法解码

时间:2018-11-06 19:09:33

标签: json scala circe

将JsonKey解码回Scala案例类时无法映射。

sealed trait Alert

@ConfiguredJsonCodec case class Free(@JsonKey("aa aa") i:Int, j:Int) extends Alert

object  Free{
  implicit val config: Configuration=Configuration.default

}

val jsonStr = """{"aa aa" : 1, "bankruptcyIndicator" : 0}"""
{
  import io.circe.generic.semiauto._
  import io.circe.jawn._
  implicit val personDec = deriveDecoder[Free]
  val person = decode[Free](jsonStr)
  println(person)
}

错误Left(DecodingFailure(Attempt to decode value on failed cursor, List(DownField(i))))

0 个答案:

没有答案