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().
Discussions

Convert JSON array to Python list - Stack Overflow
That is my JSON array, but I would want to convert all the values in the 'fruits' string to a Python list. More on stackoverflow.com
๐ŸŒ stackoverflow.com
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
Converting a JSON strings list to a JSON array in Python - Stack Overflow
How can I convert this to a JSON array? This is my desired output: [{"user": "testuser", "data": {"version": 1, "timestamp": "2018-04-03T09:23:43.388Z"}, "group": "33"}, {"user": "otheruser", "data": {"version": 2, "timestamp": "2018-04-03T09:23:43.360Z", }, "group": "44"}] I know I can do a dirty solution by just doing myJSONStringList.replace("'", ""), but is there any pythonic ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - Convert a list to json objects - Stack Overflow
As @alecxe pointed out, you need to divide the array of lists you got from the file into groups of values with 7 or fewer elements. You can then take a list of any 7 titles you want and use them as keys to create the dictionary of each json object in the final list. try: from itertools import izip except ImportError: # Python ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
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 ...
๐ŸŒ
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.
๐ŸŒ
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.
Find elsewhere
๐ŸŒ
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....
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
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"]]

๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
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...