list to json python

Do you want to know the details regarding “list to json python”. If yes, you’re in the correct tutorial.

list to json python

import json
friends_list = [
    'John','Rambo','Sam',
]
json_format = json.dumps(friends_list)
print(json_format)
print(type(json_format))
#PYTHON OUTPUT
["John", "Rambo", "Sam"]
<class 'str'>
# a Python object (dict):
x = 
  "name": "John",
  "age": 30,
  "city": "New York"


# convert into JSON:
y = json.dumps(x)

Final Words

I hope this tutorial helps you to know about “list to json python”. If you have any queries regarding this tutorial please let us know via the comment section. Share this tutorial with your friends and family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment