简体   繁体   中英

Expecting property name enclosed in double quotes

If my json file is huge it contains to many dictionaries and lists inside the dictionary and it is enclosed with double quotes means how can i proceed that. what is the deserialize? How to use the deserialize?

Use json module.

If you are having json in one file then you can use:

with open("json_data.json", "r") as data:
  print(json.load(data))

OR

with open("json_data.json", "r") as data:
  print(json.loads(data.read()))

If you are having json in any var, you can use:

jsonData = '{}'
jsonVal = json.loads(jsonData)

There is a package called json in python, which you can use to serialize and deserialize a dictionary. If you want to serialize using the following:

with open("huge_json_file.json", "r") as data
    json_str = json.dumps(data)

If you want to de-serialize using the following:

with open("huge_json_file.json", "r") as data    
    json_dict = json.loads(data)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM