0

I am trying to decode a case class from JSON which contains fields that are defined as Option[Array[T]] and get decode failure when this field is missing. The decoder from circe is the default.

case class Quotation(BasicCover: Option[BasicCover],
                   Covers: Option[Array[Cover]],
                   ContractedCovers: Option[Array[Cover]],
                   BundleCovers: Option[Array[Bundle]],
                   Insured: Option[Person],
                   Customer: Option[Person])

case class Cover(Header: Option[String], SubHeader: Option[String], ProductCode: Option[Int], ProductDescr: Option[String], DeductibleAmount: Option[String], RoomType: Option[String],
               CoverDescription: Option[String], CovCode: Option[Int])

Above are to example case classes that i am trying to decode from a JSON. Do i have to declare the Option[Array[Cover]] in a different way? Do i have to declare a specific decoder for all classes? Can i declare a decoder that handles only specific Type fields?

Dimitris
  • 13
  • 1
  • 4
  • what's the code you're using to decode ? – Arnon Rotem-Gal-Oz Apr 19 '17 at 14:39
  • yes of course i forgot it. `code` val serializedDependCoversOptionReq = inbound.head.copy(ServiceHeader(config.getString("service.serviceVersion"))) .asJson .noSpaces i use the default io.circe.{Decoder,Encoder} – Dimitris Apr 19 '17 at 22:19

0 Answers0