Skip to content

Instantly share code, notes, and snippets.

@fernaspiazu
Created September 21, 2017 22:11
Show Gist options
  • Save fernaspiazu/4c0a512bf856f77e2662a2b5c4cfa382 to your computer and use it in GitHub Desktop.
Save fernaspiazu/4c0a512bf856f77e2662a2b5c4cfa382 to your computer and use it in GitHub Desktop.
Surely, someone else found this solution... For ME it's an important discovery.
import io.circe.generic.auto._
import io.circe.syntax._
case class MoreThan22(
a1: Int, a2: Int, a3: Int, a4: Int, a5: Int, a6: Int, a7: Int, a8: Int, a9: Int, a10: Int,
a11: Int, a12: Int, a13: Int, a14: Int, a15: Int, a16: String, a17: Int, a18: Int, a19: Int, a20: Int,
a21: Int, a22: Int, a23: Int, a24: Int, a25: Int, a26: Int, a27: ComposedObj, a28: Int, a29: Int, a30: Int
)
case class ComposedObj(country: String, city: String)
val bigJson = MoreThan22(
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
"Fernando",17,18,19,20,21,22,23,24,25,26,
ComposedObj("Italy", "Milan"),28,29,30
)
val r = bigJson.asJson
// r: io.circe.Json = {
// "a1" : 1,
// "a2" : 2,
// "a3" : 3,
// "a4" : 4,
// "a5" : 5,
// "a6" : 6,
// "a7" : 7,
// "a8" : 8,
// "a9" : 9,
// "a10" : 10,
// "a11" : 11,
// "a12" : 12,
// "a13" : 13,
// "a14" : 14,
// "a15" : 15,
// "a16" : "Fernando",
// "a17" : 17,
// "a18" : 18,
// "a19" : 19,
// "a20" : 20,
// "a21" : 21,
// "a22" : 22,
// "a23" : 23,
// "a24" : 24,
// "a25" : 25,
// "a26" : 26,
// "a27" : {
// "country" : "Italy",
// "city" : "Milan"
// },
// "a28" : 28,
// "a29" : 29,
// "a30" : 30
//}
r.as[MoreThan22]
// res3: io.circe.Decoder.Result[MoreThan22] = Right(MoreThan22(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,Fernando,17,18,19,20,21,22,23,24,25,26,ComposedObj(Italy,Milan),28,29,30))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment