Convert JSON Array to String in Python Tutorial Example

07-Jun-2023

.

Admin

Convert JSON Array to String in Python Tutorial Example

Hi Dev,

Today, I will let you know an example of converting JSON array to string in a Python tutorial example. you will learn how to convert JSON to string in Python. you'll learn Python to convert JSON to string. This tutorial will give you a simple example of how to convert a JSON array to a string in Python.

Here, we will use JSON library to convert JSON to string in Python. we will create a "myJsonArray" array with website lists and convert it to string using the dumps() method into a Python list. so let's see the simple example:

Example :


main.py

import json

# python convert json to string

myJsonArray = {"websites": ["nicesnippets.com", "hdtuto.com", "itsolutionstuff.com"]}

data = json.dumps(myJsonArray)

print(data)

Output:

{"websites": ["nicesnippets.com", "hdtuto.com", "itsolutionstuff.com"]}

#Python