score:0

You can map your flat json structure to a hierarchical object structure. Then you don't need to deal with huge objects and you can have more than 22 fields.

case class SubObject(field4: String, field5:String)
case class MainObject(field1: String, field2: String, field3: String, 
subObject: SubObject, field6: String, field7: String)

implicit val mainObjectFormat: Format[MainObject] = (
    (__ \ "field1").format[String] and
    (__ \ "field2").format[String] and
    (__ \ "field3").format[String] and
    (
      (__ \ "field4").format[String] and
      (__ \ "field5").format[String]
    )(SubObject.apply, unlift(SubObject.unapply)) and
    (__ \ "field6").format[String] and
    (__ \ "field7").format[String]    
(MainObject.apply, unlift(MainObject.unapply))

Related Query

More Query from same tag