I would like to convert complex JSON into csv or fix length format.
There are multiple invoices in json file . One invoice may contain one or more lineitems.
Below is the json format and desired output. Each invoice number will be in header and all lineitems will be in DLT section. After that i will have footer as well. HDF, DLT, FTR will repeat for each invoice give in json .
{
"invoices": [
{
"INVOICE_NO": "B001R1",
"Invoice": [
{
"InvoiceNum": "B001R1",
"LesseeCode": "0G98"
}
],
"Lineitems": [
{
"InvoiceNum": "B001R1",
"LesseeCodeDetail": "0G98",
"VehicleNo": "0001B"
}
]
},
{
"INVOICE_NO": "B2r1S1",
"Invoice": [
{
"InvoiceNum": "B2r1S1",
"LesseeCode": "0G98"
}
],
"Lineitems": [
{
"InvoiceNum": "B2r1S1",
"LesseeCodeDetail": "0G98",
"VehicleNo": "12901S"
}
]
},
{
"INVOICE_NO": "B2R8S2",
"Invoice": [
{
"InvoiceNum": "B2R8S2",
"LesseeCode": "0G98"
}
],
"Lineitems": [
{
"InvoiceNum": "B2R8S2",
"LesseeCodeDetail": "0G98",
"VehicleNo": "15012S"
}
]
},
{
"INVOICE_NO": "B243861",
"Invoice": [
{
"InvoiceNum": "B243861",
"LesseeCode": "0G98"
}
],
"Lineitems": [
{
"InvoiceNum": "B243861",
"LesseeCodeDetail": "0G98",
"VehicleNo": "1S1006"
},
{
"InvoiceNum": "B243861",
"LesseeCodeDetail": "0G98",
"VehicleNo": "1S1006"
}
]
}
]
}
and here is the
