05-Jun-2023
.
Admin
Hi Dev,
This is a short guide on how to convert a JSON array to a Python list. this example will help you convert json array to a Python list. I explained simply about parsing json array to list Python. Here you will learn to convert json array into a list Python. Let's get started with how to convert a JSON array to a list in Python.
Here, we will use JSON library to convert JSON array to Python list. we will create a "myJsonArray" array with website lists and convert using the loads() method into a Python list. so let's see the simple example:
Example :
main.py
import json
# Convert JSON Array to Python List Code
myJsonArray = '{"websites": ["nicesnippets.com", "hdtuto.com", "itsolutionstuff.com"]}'
data = json.loads(myJsonArray)
print(data['websites'])
Output:
['nicesnippets.com', 'hdtuto.com', 'itsolutionstuff.com']
#Python