Convert a List to JSON in Python

  • Post category:List

Converting a list to JSON format in Python can be achieved using the json module. Here are two examples:

Example 1:

Python

Output:

JSON representation: [“apple”, “banana”, “orange”]

Example 2:

Python

Output:

JSON representation: [1, 2, 3, 4, 5]