Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse JSON multiple objects
#4
I fixed your tags in the original post. In the second post your indentation is wrong.
Also these print on line 4 and 10 will cause error. If they don't - you are using python2 and you should be using python3

Back to original post - you are overdoing things
1. Read json - get list of dicts
2.iterate over the list and parse each dict

import json

with open('party.json') as f:
    data = json.load(f)
for trade in data:
    print(trade["id"], trade["name"])
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Parse JSON multiple objects - by larkin_L - May-26-2020, 12:54 PM
RE: Parse JSON multiple objects - by pyzyx3qwerty - May-26-2020, 01:04 PM
RE: Parse JSON multiple objects - by larkin_L - May-26-2020, 01:46 PM
RE: Parse JSON multiple objects - by buran - May-26-2020, 01:53 PM
RE: Parse JSON multiple objects - by larkin_L - May-26-2020, 02:03 PM
RE: Parse JSON multiple objects - by buran - May-26-2020, 02:15 PM
RE: Parse JSON multiple objects - by nuffink - May-26-2020, 02:27 PM
RE: Parse JSON multiple objects - by pythonlearner1 - May-26-2020, 08:37 PM
RE: Parse JSON multiple objects - by nuffink - May-27-2020, 11:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to generating multiple json files using python script dzgn989 4 148 Yesterday, 03:09 PM
Last Post: deanhystad
  parse json field from csv file lebossejames 4 803 Nov-14-2023, 11:34 PM
Last Post: snippsat
  [split] Parse Nested JSON String in Python mmm07 4 1,604 Mar-28-2023, 06:07 PM
Last Post: snippsat
  Trying to parse only 3 key values from json file cubangt 8 3,556 Jul-16-2022, 02:05 PM
Last Post: deanhystad
  geojson to json --missing multiple row output yoshi 9 2,866 Mar-06-2022, 08:34 PM
Last Post: snippsat
  Problem to parse a json enigma619 3 2,421 Dec-04-2020, 08:16 AM
Last Post: enigma619
  How to parse JSON DIC? ogautier 4 2,290 Sep-15-2020, 06:03 PM
Last Post: ogautier
  Looking for help in Parse multiple XMLs and update key node values and generate Out.. rajesh3383 0 1,897 Sep-15-2020, 01:42 PM
Last Post: rajesh3383
  How can i parse a log file to JSON. menarcarlos 2 2,467 May-26-2020, 10:23 AM
Last Post: buran
  print python json dump onto multiple lines lhailey 2 19,986 Mar-02-2020, 12:47 PM
Last Post: vishalhule

Forum Jump:

User Panel Messages

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