EDIT: It should not output "notThis", because it has no inner elements.
EDIT: This post is not a duplicate as it asks for parsing the inner elements and it only asks parsing elements without inner elements.
I would like to put the root elements of a JSON array in a seperate array. Thereby I'd also like to parse the names of it's inner elements, and put them in an array with arrays of the inner elements.
See the following example:
[
{
"firstRoot": {
"firstInner1": "test",
"secondInner1": "test"
}
},
{
"secondRoot": {
"firstInner2": "test",
"secondInner2": "test"
}
},
{
"thirdRoot": {
"firstInner3": "test",
"secondInner3": "test"
}
}, {"notThis" : "test"}
]
Desired output: An array with names of all root elements:
["firstRoot", "secondRoot", "thirdRoot"]
some arrays with inner elements:
[["firstInner1","secondInner1"],["firstInner2","secondInner2"],["firstInner3","secondInner3"]]
So without the "notThis" element, because it has no inner elements.