Nested Loop/code for converting JSON in predefined CSV format
-
Hello Team,
Here is the JSON which I want to convert into CSV format.
{
"text": "2468",
"children": [
{
"text": "Union Bank",
"data": {
"subTotPending": 0,
"subTotPosted": 140577.77,
"subTotal": 140577.77
}
},
{
"text": "Bank of America",
"data": {
"subTotPending": -251522.13,
"subTotPosted": 251522.13,
"subTotal": 0
}
},
{
"text": "SubTotal",
"data": {
"subTotPosted": 392099.9,
"subTotPending": -251522.13,
"subTotal": 140577.77
}
}
],
"data": {
"subTotPosted": 392099.9,
"subTotPending": -251522.13,
"subTotal": 140577.77
}
}I am looking for converting this JSON in below format in CSV
Company,Bank Account,Posted,Pending,Ledger Balance
,,,,
2468,Union Bank,140577.77,0,140577.77
2468,Bank of America,251522.13,-251522.13,0
Sub Total,,392099.9,-251522.13,140577.77How to write the code to convert it in above CSV format.
Regards,
Amol Lokhande
-
here you have some example code that gets you an idea about how to do it.
-
Thank you so much