In this object-array, there could (!) be structure mistakes like shown below, which I need to get corrected. As you can see, data should be an array with objcts. Sometimes it is an object, which has an object. In this example the last element of group has the field "1", which is wrong. This field name could have different names. I need to remove that.
{
"group" : [
{
"title" : "title 1",
"data" : [
{
"field 1" : "Lorem ipsum",
"field 2" : "dolor"
},
{
"field 1" : "Lorem ipsum",
"field 2" : "dolor"
},
{
"field 1" : "Lorem ipsum",
"field 2" : "dolor"
}
]
},
{
"data" : { // <-- should be array
"1" : { // <-- wrong
"field 1" : "Lorem ipsum",
"field 2" : "dolor"
}
}
}
]
}
The result should be:
{
"group" : [
{
"title" : "title 1",
"data" : [
{
"field 1" : "Lorem ipsum",
"field 2" : "dolor"
},
{
"field 1" : "Lorem ipsum",
"field 2" : "dolor"
},
{
"field 1" : "Lorem ipsum",
"field 2" : "dolor"
}
]
},
{
"data" : [
{
"field 1" : "Lorem ipsum",
"field 2" : "dolor"
}
]
}
]
}