Not able to Decode when using Circe JsonKey

Viewed 721

Not able to map JsonKey when decoding it back to Scala case class.

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)
}

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

0 Answers
Related