Editor

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 lesson

You 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:

London
import json
json_str = '{"city": "London", "population": 9000000}'
# Your code here

More JSON exercises

All Python exercises · 50 practice problems · File I/O & Data Formats quiz