I have a JSON file that looks like this:
{
"Animals": [
[
543,
"Mammals",
[
1,
"Cat",
22,
45,
18
],
[
2,
"Dog",
45,
13,
27
]
]
]
}
This consists of one key - Animals - and the rest is a value expressed as a List of a List of an int, string, and list of polymorphic lists.
When attempting to parse my data structure, I used case classes as so:
sealed abstract class subTypes
case class typeOfAnimal(possSubType: String) extends subTypes
case class animalTraits(trait: Int) extends subTypes
case class animalResults(id: Int, type: String, results: List[List[subTypes]])
case class Animals(rows: List[List[animalResults]])
This fails. What is the easiest way to go about parsing such a complicated structure, deserializing from JSON to scala types.
What is the process to accomplish this?
Any tips are great.
Thanks!