Python JSON – JSON to Dictionary

In this post we will be creating a Python script that will convert JSON data to a dictionary, to help us achieve this we will be using the built-in JSON library which allows for easy encoding of Python objects into JSON format as well as the decoding of JSON data into Python objects. It can handle various data types such as lists, dictionaries, strings, and numbers.

See the snippet of Python code below where we convert our JSON data to a dictionary. Here we are using the ‘json.load()’ method to deserialize the JSON data, converting it into a dictionary which is then print to output.

import json

json_data = '{"Name": "Bobby", "Age": 28, "City": "New York"}'

data = json.loads(json_data)

print(data)

Take a look at some of our other content around the Python programming language by clicking here.

Leave a Reply