'How to explode nested columns of json file in Pyspark dynamically?

    "ID_number": 362994,
    "resultant": [
        {
            "id": 1,
            "place": {
                "codeofPlace": "I",
                "nameofPlace": "India"
            },
            "no_message": false,
            "no_email": false,
            "contact_Person": [
                "xxxxxxx"
            ],
            "lst_details": [],
            "modified": "2020-11-24T14:18:13+01:00",
            "phone_numbers": [
                {
                    "type": "mobile",
                    "number": "0000000000",
                    "id": 2,
                    "description": "yyyy"
                }
            ],
            "status": 0,
            "fields": [
                {
                    "fid": 1,
                    "id": 44,
                    "value": "True",
                }
            ],
            "farm_code": "",
            "placenumbers": [],
        },
        
    ]
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source