Python Forum
How to read json hierarchical with NO fix attributes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to read json hierarchical with NO fix attributes
#1
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
Reply


Messages In This Thread
How to read json hierarchical with NO fix attributes - by hpbr21 - Jan-22-2020, 02:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to parse and group hierarchical list items from an unindented string in Python? ann23fr 0 206 Mar-27-2024, 01:16 PM
Last Post: ann23fr
  Read nested data from JSON - Getting an error marlonbown 5 1,384 Nov-23-2022, 03:51 PM
Last Post: snippsat
  Read JSON via API and write to SQL database TecInfo 5 2,221 Aug-09-2022, 04:44 PM
Last Post: TecInfo
Question How do I skipkeys on json file read to python dictionary? BrandonKastning 3 1,902 Mar-08-2022, 09:34 PM
Last Post: BrandonKastning
  TypeError: file must have 'read' and 'readline' attributes hobbyist 6 10,958 Jun-12-2020, 05:12 PM
Last Post: DreamingInsanity
  how to read json file jk91 34 10,382 Feb-26-2020, 08:10 AM
Last Post: jk91
  read json string as dict goron 3 2,703 May-08-2019, 01:43 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020