Snatch any course you want for just $15! Go to “Courses” and find a course ↓
Reading JSON files
10. JSON parsed from a string
Summary and Review


We can get data in the form of strings, such as when we download it from the Internet or import it from a database. How can we work with such data in JSON? With the json.loads() function. It looks like this:

import json
json_string = '[{"first_name": "Guido", "last_name":"Rossum"}, {"first_name": "Alfred", "last_name":"Hitchcock"}]'
parsed_json = json.loads(json_string)

Here, we loaded the json_string string into a Python object named parsed_json. The json.loads() function creates a dictionary from a JSON string. Note that the extra "s" in "loads" means load from string.


Load the order information in json_string with the help of the json.loads() function. Calculate and print the total price of all orders.