import json

array = '{"fruits": ["apple", "banana", "orange"]}'
data  = json.loads(array)
print(data['fruits']) 
# the print displays:
# ['apple', 'banana', 'orange']

You had everything you needed. data will be a dict, and data['fruits'] will be a list

Answer from jdi on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-json-to-list
Python Json To List - GeeksforGeeks
July 23, 2025 - In this example, the below code utilizes the `json.loads()` method to convert a JSON-formatted string `[1,2,3,4]` into a Python list named `array`. The `print` statements display the type of the original string, the first element of the resulting list, and the type of the converted list, respectively.
🌐
Python Examples
pythonexamples.org › python-json-to-list
Python JSON to List
Python JSON to List - To convert a JSON String to Python List, use json.loads() function. loads() function takes JSON Array string as argument and returns a Python List. In this tutorial, we have examples to load json array string to python list.
🌐
TestMu AI Community
community.testmuai.com › ask a question
How can I convert a JSON array to a Python list? - TestMu AI Community
January 9, 2025 - I have the following JSON array: import json array = '{"fruits": ["apple", "banana", "orange"]}' data = json.loads(array) In this case, I want to convert all the values in the ‘fruits’ string to a Python list. What is…
🌐
CodeSpeedy
codespeedy.com › home › convert json to list in python
Convert JSON to list in Python - CodeSpeedy
July 9, 2019 - Initially, we declared a JSON array, ‘array’ which is a string. json.loads(array) converts JSON array to Python object i.e. list (here) and the value is stored in data variable. Then by using the print statement, we printed out the Python list.
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-python-list-to-json
Convert Python List to Json - GeeksforGeeks
July 23, 2025 - JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy for humans to read and write, and easy for machines to parse and generate. In Python, the json module provides a convenient way to work with JSON data. In this article, we'll explore how to convert Python lists to JSON, along with some examples.
🌐
ItSolutionstuff
itsolutionstuff.com › post › convert-json-array-to-python-list-exampleexample.html
Convert JSON Array to Python List Example - ItSolutionstuff.com
October 30, 2023 - import json # Convert JSON Array to Python List Code myJsonArray = '{"websites": ["itsolutionstuff.com", "hdtuto.com", "nicesnippets.com"]}' data = json.loads(myJsonArray) print(data['websites'])
Find elsewhere
🌐
W3Schools
w3schools.com › python › python_json.asp
Python JSON
Remove List Duplicates Reverse a String Add Two Numbers · Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... JSON is a syntax for storing and exchanging data. JSON is text, written with JavaScript object notation. Python has a built-in package called json, which can be used to work with JSON data.
🌐
DataCamp
datacamp.com › tutorial › json-data-python
Python JSON Data: A Guide With Examples | DataCamp
December 3, 2024 - While Python is capable of storing intricate data structures such as sets and dictionaries, JSON is limited to handling strings, numbers, booleans, arrays, and objects. Let’s look at some of the differences: To convert a Python list to JSON format, you can use the json.dumps() method from ...
🌐
Reddit
reddit.com › r/learnpython › convert json list to dictionary
r/learnpython on Reddit: convert JSON list to dictionary
January 13, 2024 -

I must first preface this with the fact that I’m extremely new to python. Like just started learning it a little over a week ago.
I have been racking my brain over how to convert a json object I opened and loaded into a dictionary from a list so I can use the get() function nested within a for loop to do a student ID comparison from another json file (key name in that file is just ID).
Below is the command I’m trying to load the json file:
With open(‘file.json’) as x: object=json.load(x)
When I print(type(object)), it shows up as class list.
Here’s a sample of what the json looks like:
[

{

“Name”: “Steel”,

“StudentID”: 3458274

“Tuition”: 24.99

},

{

“Name”: “Joe”,

“StudentID”: 5927592

“Tuition”: 14.99

}

]
HELP! Thank you!

🌐
Quora
quora.com › How-do-I-convert-a-list-to-JSON-in-Python
How to convert a list to JSON in Python - Quora
Answer (1 of 10): This is pretty basic. There is a inbuilt package which python provides called json. Simply import it then make a simple list and then write json.dumps(list). I think it will do the job. Another way to do : but its beneficial for large no. Of datas. You can convert the list to...
🌐
GeeksforGeeks
geeksforgeeks.org › python › loop-through-a-json-array-in-python
Loop through a JSON array in Python - GeeksforGeeks
July 23, 2025 - In this example, we will define the JSON data as a string and load it using the and the load() function to convert the JSON data to a Python object. Then using a for loop we will iterate through the array.
🌐
Python Guides
pythonguides.com › json-data-in-python
How To Get Values From A JSON Array In Python?
November 29, 2024 - Let me show you another way to extract values from a JSON array is: by using list comprehension. List comprehension allows you to create a new list based on an existing list or iterable. Here’s an example: import json # Load JSON data from file with open('C:/Users/fewli/Downloads/Python/states.json') as file: data = json.load(file) state_names = [state['name'] for state in data] print("State Names:", state_names)
🌐
Workato
systematic.workato.com › t5 › workato-pros-discussion-board › quot-help-with-parsing-json-string-into-python-list-getting › td-p › 8578
Solved: "Help with Parsing JSON String into Python List – ... - Systematic Community - 8578
January 30, 2025 - When I run this, I get the error: "TypeError: the JSON object must be str, bytes or bytearray, not NoneType". What could be causing this, and how can I fix it? Any help would be appreciated! Solved! Go to Solution. ... Hi @Patel0786 , In the 4th line please pass the output of 3rd line ( i.e. string_data). Please try and let me know. Thanks and Regards, Shivakumara K ... Python interprets this as a list of dictionaries because single quotes are valid for dictionary keys/values in Python.
🌐
Python.org
discuss.python.org › python help
Unable to append data to Json array object with desired output - Python Help - Discussions on Python.org
January 18, 2023 - I’m tried getting help for same issue on stack-overflow but got no help or replies. I’m re-posting here with the hope that someone can please guide me as I’m unable to push the code to repository due to delay. My code import json import re from http.client import responses import vt import requests with open('/home/asad/Downloads/ssh-log-parser/ok.txt', 'r') as file: file = file.read() pattern = re.compile(r'\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}') ips = pattern.findall(file) unique_ips = lis...
Top answer
1 of 2
5

What you are looking to do is deserialize a json object to a class, I'm sure there are better answers than this one but here goes.

First Step: convert json array to python list

import json
# assuming it is a json object for now, you can loop through an do the same
json = {'completed': 0, 'content': 'do smtng', 'deadline': 'Mon, 22 Nov 2021 00:00:00 GMT', 'id': 4, 'user_id': 7}
job = json.loads(json)

Second Step: Converting our list to a class

There's not really a consensus here on how to do this. You can try libraries like attrs if your json is already formatted with the exact naming of your class, or you can do something manual like this:

import json
from dataclasses import dataclass


@dataclass
class Task:
    completed: int
    content: str
    deadline: str
    id: int
    user_id: int
    
    @classmethod
    def from_dict(cls, dict):
        return cls(completed=dict["completed"], content=dict["content"],
                   deadline=dict["deadline"], id=dict["id"],
                   user_id=dict["user_id"])

    @classmethod
    def from_json(cls, json_str: str):
        return cls.from_dict(json.loads(json_str))

You can perform input validation here too if you want but trying to keep it basic

2 of 2
2

If you're ok with using external libraries, the simplest solution would be to use the builtin dataclasses module in Python 3.7+ along with the dataclass-wizard library for (de)serialization purposes.

Here's a simple enough example using data classes to model your data in this case. Note that I'm using a new feature, patterned date and time, to de-serialize a custom pattern string to a datetime object. If you want to keep the data as a string, you can annotate it just like deadline: str instead. I was able to use the format codes from the docs on datetime.

import json
from dataclasses import dataclass

from dataclass_wizard import fromlist, asdict, DateTimePattern


@dataclass
class Task:
    completed: int
    content: str
    deadline: DateTimePattern['%a, %d %b %Y %H:%M:%S %Z']
    id: int
    user_id: int


list_of_dict = [
    {'completed': 0, 'content': 'do smtng', 'deadline': 'Mon, 22 Nov 2021 00:00:00 GMT', 'id': 4, 'user_id': 7},
]

# De-serialize JSON data into a list of Task instances
list_of_tasks = fromlist(Task, list_of_dict)
print(list_of_tasks)

# Serialize list of Task instances
json_string = json.dumps([asdict(task) for task in list_of_tasks])
print(json_string)

Output:

[Task(completed=0, content='do smtng', deadline=datetime.datetime(2021, 11, 22, 0, 0), id=4, user_id=7)]
[{"completed": 0, "content": "do smtng", "deadline": "2021-11-22T00:00:00", "id": 4, "userId": 7}]

To make things a bit simpler, you can opt to subclass from the JSONWizard Mixin class. The main benefit here is a bunch of added helper class methods, like list_to_json which will serialize a list of dataclass instances to JSON, which seems like it could be useful in this case. This example is similar to the one above; note the output is the same in any case.

from dataclasses import dataclass

from dataclass_wizard import JSONWizard, DateTimePattern


@dataclass
class Task(JSONWizard):
    completed: int
    content: str
    deadline: DateTimePattern['%a, %d %b %Y %H:%M:%S %Z']
    id: int
    user_id: int


list_of_dict = [
    {'completed': 0, 'content': 'do smtng', 'deadline': 'Mon, 22 Nov 2021 00:00:00 GMT', 'id': 4, 'user_id': 7},
]

# De-serialize JSON data into a list of Task instances
list_of_tasks = Task.from_list(list_of_dict)
print(list_of_tasks)

# Serialize list of Task instances
json_string = Task.list_to_json(list_of_tasks)
print(json_string)
🌐
ReqBin
reqbin.com › json › python › uzykkick › json-array-example
Python | What is JSON Array?
The following is an example of a JSON array with numbers. Below, you can find a list of JSON arrays with different data types. The Python code was automatically generated for the JSON Array example. ... This Python code snippet was generated automatically for the JSON Array example. << Back to the ...
🌐
Reddit
reddit.com › r/learnpython › list all json keys in a file to identify database column names from a file using python
r/learnpython on Reddit: List all JSON keys in a file to identify database column names from a file using Python
July 9, 2022 -

I am learning Python, and in particular, working with JSON and sqlite in Python. Ultimately I plan to use Python to load the JSON into a sqlite database.

Here is the question: Is there a way in to list all of the keys from a JSON file (not from a string) using Python? I want a list of all of the keys so I can determine what columns I will need/use in my sqlite table(s), without having to manually read the file and make a list.

BTW, this is something along the lines of using INFORMATION_SCHEMA.COLUMNS in SQL Server, or the FINDALL in Python for XML.

All of this is for personal learning, so I'm not looking to use other technologies, I'm sticking to Python, JSON, and sqlite on purpose.