Parse a JSON String
Beginner · Write the code · from Python JSON: Parse, Create, and Manipulate JSON Data
From the lesson: Python JSON: Parse, Create, and Manipulate JSON Data
Imagine a universal language that every app, website, and database can understand. That's JSON (JavaScript Object Notation). It's the most popular format for sending data between computers.
Read the lessonYou are given a JSON string stored in json_str. Parse it into a Python dictionary and print the value of the 'city' key.
json_str = '{"city": "London", "population": 9000000}'Expected output:
Londonimport json
json_str = '{"city": "London", "population": 9000000}'
# Your code here
More JSON exercises
- Predict the JSON OutputBeginner
- Create Pretty JSONIntermediate
- Fix the JSON Parsing BugIntermediate
- Refactor String Concatenation to json.dumpsIntermediate
- Extract Data from Nested API JSONAdvanced
All Python exercises · 50 practice problems · File I/O & Data Formats quiz