Just adding onto alexce's response, you can easily convert the restructured data into JSON:

import json
json.dumps(result)

There are some potential security concerns with top-level arrays. I'm not sure if they're still valid with modern browsers, but you may want to consider wrapping it in an object.

import json
json.dumps({'results': result})
Answer from ngraves on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-python-list-to-json
Convert Python List to Json - GeeksforGeeks
July 23, 2025 - In this example, a Python list containing a mix of integers and strings (list_1) is converted to a JSON-formatted string (json_str) using json.dumps().
Discussions

How to convert nested list into JSON?
json.dumps can handle nested data structures, too. More on reddit.com
🌐 r/learnpython
6
3
June 23, 2018
json - How to convert a list of numbers to jsonarray in Python - Stack Overflow
``` >>> import json >>> row = ... >>> row_json = json.dumps(row) >>> type(row_json) >>> ``` 2019-02-22T12:57:52.04Z+00:00 ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 0 How to convert data fetched from a database using python into a JSON ... More on stackoverflow.com
🌐 stackoverflow.com
convert JSON list to dictionary
If I'm not wrong, your JSON file is a list of dictionaries. Which means, you can iterate over the loop to access each dictionary, upon which you can use the relevant method to get the student id. You can connect with me on loljaegar@gmail.com if you wanna screen share and discuss. More on reddit.com
🌐 r/learnpython
8
0
January 13, 2024
convert list of dictionary to list of json objects
Json.dumps will convert the dictionary to a string but the string is valid JSON. You see the single quotes since Python is indicating this is a string (and double quotes is being used internally). More on reddit.com
🌐 r/learnpython
7
2
October 13, 2022
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › convert python list to json examples
Convert Python List to JSON Examples - Spark By {Examples}
March 27, 2024 - How to convert a list to JSON in Python? You can use the json.dumps() method to convert a Python list to a JSON string. This function takes a list as an argument and returns the JSON value.
🌐
AskPython
askpython.com › home › convert a list to json string in python [easy step-by-step]
Convert a List to JSON String in Python [Easy Step-By-Step] - AskPython
May 30, 2023 - The dumps() function takes a Python list as its parameter, converts it into a JSON string, and then returns that JSON string. The syntax for using the dumps() function is given below.
🌐
Medium
medium.com › @wepypixel › how-to-convert-a-list-to-json-python-simple-technique-pypixel-c329f6de5d7a
How to Convert a List to JSON Python? Simple Technique -PyPixel | by Stilest | Medium
August 26, 2023 - First, we will be importing Python’s in-built json module into your Python script by adding this line of code: ... Now just for an example, we will create a dummy list that we will further use to convert the list to JSON in Python:
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-convert-list-of-dictionaries-to-json
Python - Convert list of dictionaries to JSON - GeeksforGeeks
July 5, 2025 - Let’s explore several efficient methods to perform this conversion. json.dumps() method converts a Python object into a JSON-formatted string. It’s useful when you want to display or transmit JSON data without writing to a file.
Find elsewhere
🌐
Python Examples
pythonexamples.org › python-list-to-json
Python List to JSON
import json a_list = [{'a':1, 'b':2}, {'c':3, 'd':4}] json_string = json.dumps(a_list) print(json_string) ... In this example, we will take a Python List of Lists and convert it to JSON string.
🌐
Reddit
reddit.com › r/learnpython › how to convert nested list into json?
r/learnpython on Reddit: How to convert nested list into JSON?
June 23, 2018 -

I know that, list can be converted into JSON by using json.dumps(mylist).

But how can I convert something like this into JSON ?

[["abc", "bcd", "cde"] , ["pgr", "xyz"]]

🌐
W3Schools
w3schools.com › python › gloss_python_convert_into_JSON.asp
Python Convert From Python to JSON
Remove List Duplicates Reverse ... ... If you have a Python object, you can convert it into a JSON string by using the json.dumps() method....
🌐
W3Schools
w3schools.com › python › python_json.asp
Python JSON
Convert from Python to JSON: import json # a Python object (dict): x = { "name": "John", "age": 30, "city": "New York" } # convert into JSON: y = json.dumps(x) # the result is a JSON string: print(y) Try it Yourself » · You can convert Python objects of the following types, into JSON strings: dict · list ·
🌐
Medium
medium.com › @zeebrockeraa › how-to-convert-python-list-to-json-3a0485f39c7e
How to convert Python List to JSON - Zeeshan Ali - Medium
July 12, 2023 - my_list = [1, 2, 3, 4, 5]# Convert the list to JSON format json_data = json.dumps(my_list)print(json_data) In the code above, we import the json module and create a Python list called my_list containing some elements. Then we use the json.dumps() ...
🌐
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 ...
🌐
Finxter
blog.finxter.com › 5-best-ways-to-convert-a-python-list-to-json
5 Best Ways to Convert a Python List to JSON – Be on the Right Side of Change
February 20, 2024 - The json.dumps() method in Python can be used to convert a list to a JSON formatted string.
🌐
Appdividend
appdividend.com › python-list-to-json
How to Convert List to JSON in Python (Variables and Files)
November 24, 2025 - The most efficient and straightforward way to convert a Python List is by using the json.dumps() method.
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-list-of-tuples-to-json-python
Convert List Of Tuples To Json Python - GeeksforGeeks
July 23, 2025 - In this example, the json.dumps() function is employed to convert a list of tuples (list_of_tuples) into a JSON-formatted string (json_data).
🌐
Statistics Globe
statisticsglobe.com › home › python programming language for statistics & data science › convert list to json object & vice versa in python (examples)
Convert List to JSON Object & Vice Versa in Python (4 Examples)
May 16, 2023 - In the example, we parsed the JSON object to the ast.literal_eval() function, which then returned a Python list object. With that, we have demonstrated how to convert a list to a JSON object and vice-versa in Python.
🌐
DEV Community
dev.to › wepypixel › how-to-convert-a-list-to-json-python-best-simple-technique-2oee
How to Convert a List to JSON Python? Best Simple Technique - DEV Community
September 10, 2023 - First we will be importing the Python’s in-built json module into your Python script by adding this line of code: ... Now just for an example we will create a dummy list that we will further used to convert list to json in python:
🌐
Linux Hint
linuxhint.com › python-list-to-json
Python List to JSON
October 20, 2021 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use