1import json
2friends_list = [
3 'John','Rambo','Sam',
4]
5json_format = json.dumps(friends_list)
6print(json_format)
7print(type(json_format))
8#PYTHON OUTPUT
9["John", "Rambo", "Sam"]
10<class 'str'>
1# a Python object (dict):
2x = {
3 "name": "John",
4 "age": 30,
5 "city": "New York"
6}
7
8# convert into JSON:
9y = json.dumps(x)