I'm working on a JSON file with nested objects and would like to extract the child objects without converting them to their Scala case class equivalents. Is there any pre-built functionality to filter out chunks of JSON text this way?
For example, if I've got a JSON file with content similar to this:
{
"parentObject": "bob",
"parentDetail1": "foo",
"subObjects": [
{
"childObjectName": "childname1",
"detail1": "randominfo1",
"detail2": "randominfo1"
},
{
"childObjectName": "childname2",
"detail1": "randominfo2",
"detail2": "randominfo2"
},
{
"childObjectName": "childname3",
"detail1": "randominfo3",
"detail2": "randominfo3"
}
]
}
I would like to extract the subObjects nodes, ideally as individual chunks of JSON text (perhaps as an String Array with each subObject as an element). I know I could parse the entire JSON file into objects I've pre-defined in Scala classes, but would rather not take that route since this will probably be too expensive for larger files. I'm looking for a simple and elegant way to go here. Any ideas?