I have huge nested JSON that is being fed as a n input to the API. The input JSON looks like:
[{
"ID": "123456",
"accountNumber": "876545",
"contractType": "ABCD",
"linedata":
{
"productSKU": "1234",
"data": {
"Line_Number": 1726428,
"Reservation_Number": "1726428",
"Quantity": 1,
"UnitPrice": 16,
}
}
},
{
"ID": "345678",
"accountNumber": "445566",
"contractType": "ABCD",
"linedata":
{
"productSKU": "2345",
"data": {
"Line_Number": 3213445565,
"Reservation_Number": "123456789",
"Quantity": 1,
"UnitPrice": 25,
}
}
}]
I need to convert this into a CSV flat fromat retaining the JSON elements for linedata attribute which looks like:
Data, ID, AccountNumber, Contract_Type
{"productSKU":"1234","data":{"Line_Number":1726428, "Reservation_Number":"1726428", "Quantity":1, "UnitPrice":15}}, 123456, 876545, ABCD
{"productSKU":"1234","data":{"Line_Number":1726428, "Reservation_Number":"1726428", "Quantity":1, "UnitPrice":15}}, 345678, 445566, ABCD
The problem is that when I try to concatenate the linedata attribute as string, I am left with backslashes in the output and all my attempts to remove those bacslashes have gone in vain. Seems like I am missing something basic here. What is the best way to achieve this ?