Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

mule - Unable to transform Complex JSON Object to CSV using Dataweave

Need some guidance or hint in transforming this complex json object to csv. I personally feel that my input data is incorrect or not proper which I designed from my previous flows and obtained this as a result. Any suggestions in modifying my input json object and obtaining the desired result will also be helpful for me.

Note - As here in this example there is one APD in each API, similarly there are many API and APD. Just attached a part of my Json Object.

Input Json Object

{
    "API": {
        "VendorID": "39594",
        "InvoiceName": "December Expenses (12/01/2020)",
        "Description": "HectorEchiveste",
        "SumInvoiceAmount": 622.02,
        "InvAcctDate": "1222021",
        "InvAcctDate2": "1222021",
        "APD": {
            "JobNumber": [
                "",
                "C8D-27-14387",
                "",
                "",
                "CL5-27-11934",
                "CL5-27-11934",
                "",
                "",
                "",
                ""
            ],
            "CostCode": [
                "",
                "1000",
                "",
                "",
                "1000",
                "1000",
                "",
                "",
                "",
                ""
            ],
            "CostCategory": [
                "",
                "M",
                "",
                "",
                "O",
                "O",
                "",
                "",
                "",
                ""
            ],
            "GL": [
                "1-20-70-6600",
                "1-20-70-5200",
                "1-20-70-6600",
                "1-20-70-6600",
                "1-20-70-5500",
                "1-20-70-5500",
                "1-20-70-6600",
                "1-20-70-6600",
                "1-20-70-6600",
                "1-20-70-6600"
            ],
            "Amount": [
                "60.00",
                "166.17",
                "51.34",
                "60.00",
                "67.75",
                "9.00",
                "45.00",
                "48.75",
                "50.00",
                "64.01"
            ]
        }
    },
    "API": {
        "VendorID": "39849",
        "InvoiceName": "December Expenses (12/01/2020)",
        "Description": "DonaldOrtega",
        "SumInvoiceAmount": 223.08,
        "InvAcctDate": "1252021",
        "InvAcctDate2": "1252021",
        "APD": {
            "JobNumber": [
                "B8G-87-15555"
            ],
            "CostCode": [
                "1000"
            ],
            "CostCategory": [
                "M"
            ],
            "GL": [
                "1-80-70-5200"
            ],
            "Amount": [
                "223.08"
            ]
        }
    }

Required Csv format csv format

question from:https://stackoverflow.com/questions/65943364/unable-to-transform-complex-json-object-to-csv-using-dataweave

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Can you check your payload? I'm getting this error.

Unexpected character ']' at payload@[96:6] (line:column), expected '}'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...