0

I am new to python. Trying to parse nested json and convert to csv. Tried various solutions available in other posts like Dictwriter etc but only able to get the last record of the data. The json structures are dynamic i.e. depth cant be specified. I am looking for a generic solution without hard-coding any variable.

Below is the sample data

{
    "documentType": "Rec",
    "filters": [
        {
            "name": "pc",
            "type": "string",
            "size": 50,
            "allowedValues": null,
            "isCus": false,
            "pre": null,
            "fdn": "Unique Name",
            "scale": null
        },
        {
            "name": "Ss",
            "type": "string",
            "size": 50,
            "allowedValues": null,
            "isCus": false,
            "precision": null,
            "fdn": "Status String",
            "scale": null
        }
    ],
    "selections": [
        {
            "name": "R.notify",
            "type": "boolean",
            "size": null,
            "allowedValues": null,
            "isCus": false,
            "precision": null,
            "fdn": "Notify",
            "scale": null
        },
        {
            "name": "intit",
            "type": "string",
            "size": 255,
            "allowedValues": null,
            "isCus": false,
            "precision": null,
            "fdn": "Initialization",
            "scale": null
        }
    ]
}

Expected output

"documentType","","name","type","size","allowedValues","isCus","precision","pre","fdn","scale"
"Rec","filters","pc","string","50","null","False","","null","Unique Name","null"
"","","Ss","string","50","null","False","null","","Status String","null"
"","selections","R.notify","boolean","null","null","False","null","","Notify","null"
"","","intit","string","255","null","False","null","","Initialization","null"

0 Answers0