Consider the following example JSON:
properties: {
"key1": "a",
"key2": 1,
"key3": null,
"key4": 0.56
....
"key99": "zzzzz"
}
My code needs to be able to parse that into some sort of Scala structure (case class?) and back into JSON.
To me, since there are not a finite number of elements inside of properties
, this looks like a Map[String, T]
. And since the value of each inner property can be of multiple types, I'm not entirely sure how to represent that as a finite Scala structure. The documentation on implicit Reads
, Writes
, and Formats
make sense to me, but they don't seem to handle more complicated examples, like the above.
It's also entirely possible I'm thinking about this completely wrong.
I'm new to the framework (as well as the language) and I'm having a hard time wrapping my head around how this should be represented -- any insight would be greatly appreciated.
JsValue
. This feels like I'm side-stepping the actual issue though; I'm still interested in how you'd accomplish such a thing.