Here is sample JSON data. It has one 'PO' and inside 'PO' there are multiple 'SO' nodes. Inside an 'SO' node there can be multiple nodes each containing one 'B', 'R', 'F'.
{
"PO": [
{
"SO": [
{
"B": "XXX",
"R": "YYY",
"F": "ZZZ"
},
{
"B": "MMM",
"R": "NNN",
"F": "PPP"
}
],
"SO": [
{
"B": "111",
"R": "222",
"F": "333"
},
{
"B": "333",
"R": "444",
"F": "555"
},
{
"B": "666",
"R": "777",
"F": "888"
}
]
}
]
}
I want this data to be like this
{
"PO": [
{
"B": "XXX",
"R": "YYY",
"F": "ZZZ"
},
{
"B": "MMM",
"R": "NNN",
"F": "PPP"
},
{
"B": "111",
"R": "222",
"F": "333"
},
{
"B": "333",
"R": "444",
"F": "555"
},
{
"B": "666",
"R": "777",
"F": "888"
}
]
}
How can I do this in Javascript?
I tried obj.PO[0].SO
where obj is the JSON object and some replace functions to replace the 'SO' nodes, but couldn't get it to work.