I need a JSON path to return all the fields while inputting the JSON array. It is like converting array JSON to flat JSON file.
Array JSON input:
{
"field1": "ALNT12345",
"field2": "ALNT345346",
"field3": "2015353423",
"field4": "2332124343",
"arrayfield1": [
{
"arr1": "625347",
"arr2": "rere"
},
{
"arr1": "634441",
"arr2": "sdfsd"
}
]
}
The above array json must be converted to 2 records as shown below. So, i am trying to achieve this using json path.
Required Output:
[
{
"field1": "ALNT12345",
"field2": "ALNT345346",
"field3": "2015353423",
"field4": "2332124343",
"arr1": "625347",
"arr2": "rere"
},
{
"field1": "ALNT12345",
"field2": "ALNT345346",
"field3": "2015353423",
"field4": "2332124343",
"arr1": "634441",
"arr2": "sdfsd"
}
]
What I tried is in JSON path,
$.arrayfield1.*
But it returning only array fields. If JSON path is not the way to achieve this, can you please suggest javascript code to return all the fields.
thanks.