Python Forum
How to read json hierarchical with NO fix attributes - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to read json hierarchical with NO fix attributes (/thread-23904.html)



How to read json hierarchical with NO fix attributes - hpbr21 - Jan-22-2020

My Json is as below:

{"Parties":[{"PartyRoleCode":"Customer","PartyBECountry":"GB","PartyBECode":"PRIMARK","PartyBEFunction":"HQ"},{"PartyRoleCode":"Seller","PartyAlias":"TESTING"},{"PartyRoleCode":"Factory","PartyAlias":"TESTING"},{"PartyRoleCode":"Consignee","PartyAlias":"TESTING"},{"PartyRoleCode":"Shipper","PartyAlias":"CN AS VDR"},{"PartyRoleCode":"Buyer","PartyAlias":"TESTING"},{"PartyRoleCode":"NotifyParty","PartyAlias":"TESTING"},{"PartyRoleCode":"Consolidator","PartyAlias":"TESTING"},{"PartyRoleCode":"ShipTo","PartyAlias":"TESTING"},{"PartyRoleCode":"ContainerStuffingLocation","PartyAlias":"TESTING"}]}

for Parties key, I want to iterate and write these data in data frame, How should I do it.Finally I want to write this dataframe in parquet file.

I will be using this python(version 3) code in databricks

If yo observe the attributes are not same for all rows


RE: How to read json hierarchical with NO fix attributes - micseydel - Jan-22-2020

What have you tried?