Use the json module to produce JSON output:

import json

with open(outputfilename, 'wb') as outfile:
    json.dump(row, outfile)

This writes the JSON result directly to the file (replacing any previous content if the file already existed).

If you need the JSON result string in Python itself, use json.dumps() (added s, for 'string'):

json_string = json.dumps(row)

The L is just Python syntax for a long integer value; the json library knows how to handle those values, no L will be written.

Demo string output:

>>> import json
>>> row = [1L,[0.1,0.2],[[1234L,1],[134L,2]]]
>>> json.dumps(row)
'[1, [0.1, 0.2], [[1234, 1], [134, 2]]]'
Answer from Martijn Pieters 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().
๐ŸŒ
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.
๐ŸŒ
Tech With Tech
techwithtech.com โ€บ home โ€บ converting list to json array in python: how to?
Converting List to JSON Array in Python: How To? - Tech With Tech
October 27, 2022 - You can import it like this: ... ... similar structure to JSON arrays, so they are converted directly to JSON arrays by using the dumps method:...
๐ŸŒ
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.
๐ŸŒ
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.
Find elsewhere
๐ŸŒ
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
๐ŸŒ
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 ...
๐ŸŒ
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.
๐ŸŒ
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 - 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. This module provides methods to serialize Python objects into JSON format and deserialize JSON data back into Python objects.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-convert-list-of-dictionaries-to-json
Python - Convert list of dictionaries to JSON - GeeksforGeeks
December 12, 2023 - The task of converting lists to a nested dictionary in Python involves mapping elements from multiple lists into key-value pairs, where each key is associated with a nested dictionary. For example, given the lists a = ["gfg", "is", "best"], b = ["ratings", "price", "score"], and c = [5, 6, 7], the g ... Let us see how to convert a given nested dictionary into an object Method 1 : Using the json module.
๐ŸŒ
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 Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp 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.
๐ŸŒ
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 - 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. This module provides methods to serialize Python objects into JSON format and deserialize JSON data back into Python objects.