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 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. ... 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
If you need the JSON result string in Python itself, use json.dumps() (added s, for 'string'): 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
๐ŸŒ
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.
๐ŸŒ
Quora
quora.com โ€บ How-do-I-convert-a-list-to-JSON-in-Python
How to convert a list to JSON in Python - Quora
To convert a Python List to JSON, use json. dumps() function. dumps() function takes list as argument and returns a JSON String.
๐ŸŒ
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 - We can also convert list of dictionaries to a JSON string by using json.dumps() function. For example, we will create a Python list of dictionaries containing the odd, even, and prime numbersโ€™ lists corresponding to their keys (labels).
๐ŸŒ
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.
๐ŸŒ
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 - Now just for an example, we will create a dummy list that we will further use to convert the list to JSON in Python: ... With the json module that we imported earlier, we can employ the json.dumps() function to transform the Python list into ...
Find elsewhere
๐ŸŒ
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"]]

๐ŸŒ
YouTube
youtube.com โ€บ watch
convert list to JSON Python - YouTube
This video explains how to convert python list to JSON.A simple list, list of lists and list of dictionaries are taken as examples and converted to JSON.Othe...
Published ย  December 9, 2021
๐ŸŒ
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 ยท
๐ŸŒ
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
๐ŸŒ
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....
๐ŸŒ
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. It accepts a list as an argument and returns a string representation of a valid JSON structure.
๐ŸŒ
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.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-convert-list-of-dictionaries-to-json
Python - Convert list of dictionaries to JSON - GeeksforGeeks
December 12, 2023 - In this example, the Python json module is utilized to handle non-serializable types within a list of dictionaries during JSON encoding. Here, we will convert list to json file python. The default parameter of json.dumps() is employed with a lambda function, converting tuple objects to lists and ensuring proper serialization, resulting in a formatted JSON string with indents for clarity
๐ŸŒ
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 ...
๐ŸŒ
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 - 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() function to convert the list to a JSON-formatted string.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ convert-list-of-tuples-to-json-string-in-python
Convert List Of Tuples To Json String in Python - GeeksforGeeks
July 23, 2025 - In this example, below Python code below converts a list of tuples into a JSON string using the `JSON` module. It employs a mapping function to transform each tuple into a dictionary, then uses `map` and `below n.dumps` for the conversion.
๐ŸŒ
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 - Now just for an example we will create a dummy list that we will further used to convert list to json in python: ... With the json module that we imported earlier, we can employ the json.dumps() function to transform the Python list into a ...