Use json dumps() to convert a list to a JSON array in Python. The dumps() function takes a list as an argument and returns a JSON String.
Python list to JSON array example
Simple example code converting given list
["1", "2", "3"] to a JSON array results in the string
'["1", "2", "3"]'.
For this example, you have to import a JSON module into the project file.
import json aList = ["1", "2", "3"] res = json.dumps(aList) print(res) print(type(res))
Do comment if you have any doubts or suggestions on this Python JSON and List topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.