4

I am working on a very big JSON file, and I decided to use the ijson library.

Now I want to update some value in this JSON file, but I don't know how.

For example, from:

{"age": 25, "gender": "M"}

update to:

{"age": 30, "gender": "F"}

by using the ijson library.

jwodder
  • 54,758
  • 12
  • 108
  • 124

1 Answers1

1

Refer the examples in https://pypi.python.org/pypi/ijson/. For editing you can simply use the json library. First load/deserialize the json object then edit and finally use the dump method to update your json file.

Shivam Chaurasia
  • 474
  • 5
  • 21
  • 2
    Thanks, yes, I already thought this, but the problem is that if the file is very large (Gbs), only load the file by using json library requires a lot of time. Is there a way to address this issue? – Luca Marchetti May 04 '17 at 20:51
  • 2
    You can use pandas dataframes or graphlab SFrame to load large json files. Also both the libraries are more stable than ijson streaming. – Shivam Chaurasia May 04 '17 at 21:03