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
🌐
Python Examples
pythonexamples.org › python-list-to-json
Python List to JSON
In this example, we will take a Python List with Dictionaries as elements and convert it to JSON string. 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.
🌐
AskPython
askpython.com › python › list › convert-list-to-json
Convert a List to JSON String in Python [Easy Step-By-Step] - AskPython
July 20, 2021 - By converting a Python list to JSON, one can utilise its powerful features. We can use the Python json module to convert the Python list to a JSON string.
🌐
Makeinjava
makeinjava.com › home › convert list of objects to/from json in java (jackson objectmapper/ example)
Convert list of objects to/from JSON in java (jackson objectmapper/example)
January 1, 2024 - Convert List of Person objects to JSON String arrayToJson = objectMapper.writeValueAsString(personList); System.out.println("1. Convert List of person objects to JSON :"); System.out.println(arrayToJson); //2.
🌐
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. ... 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().
Find elsewhere
🌐
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 - JSON is widely used for data exchange between a server and a web application, configuration storage, and various other applications due to its simplicity and readability. It’s a collection of key-value pairs, where values can be strings, numbers, objects, arrays, booleans, or nulls. Its versatility and simplicity make it a preferred choice for data representation. To convert a Python list to a JSON, we can make use of Python’s built-in json module, we do not need to explicitly install it.
🌐
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 - JSON is widely used for data exchange between a server and a web application, configuration storage, and various other applications due to its simplicity and readability. It’s a collection of key-value pairs, where values can be strings, numbers, objects, arrays, booleans, or nulls. Its versatility and simplicity make it a preferred choice for data representation. To convert a Python list to a JSON, we can make use of Python’s built-in json module, we do not need to explicitly install it.
🌐
Baeldung
baeldung.com › home › java › java list › converting a java list to a json array
Converting a Java List to a Json Array | Baeldung
June 18, 2025 - We aim to convert this “articles” list into a JSON array. So, the expected output should be as follows: ... We’ll explore three different approaches in the following sections to accomplish the conversion task. Gson is a popular Java library developed by Google for working with JSON data since it provides a simple API for converting Java objects to JSON. First of all, we need to add the Gson dependency to the pom.xml file:
🌐
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 › java › how-to-convert-an-arraylist-of-objects-to-a-json-array-in-java
How to Convert an ArrayList of Objects to a JSON Array in Java? - GeeksforGeeks
July 23, 2025 - The writeValueAsString method converts the ArrayList to a JSON string which is printed. Any exceptions during conversion are caught and printed. ... Help us improve. Share your suggestions to enhance the article.
🌐
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
🌐
BezKoder
bezkoder.com › home › dart/flutter – convert object, list to json string
Dart/Flutter – Convert Object, List to JSON string - BezKoder
March 16, 2022 - Related Posts: – Dart/Flutter ... Tutorial with Examples ... dart:convert library provides a built-in top-level function called jsonEncode that can convert many types of Object to JSON string....
🌐
Quora
quora.com › How-do-I-convert-a-list-to-JSON-in-Java
How to convert a list to JSON in Java - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
Atlassian Community
community.atlassian.com › q&a › atlassian automation › questions › converting list to json object
Solved: Converting list to JSON object
December 5, 2023 - Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions. ... I have a variable (mylist) with list such as 50810, 50811 which is populated from a web request. I was able to convert it into an array like ["50810", "50811"] using .asJsonStringArray · Ultimately, I want to convert it into JSON object like [{ "mykey" : "50810"}, {"mykey" : "50811"}] so I can update a custom multi select field.