Python ProgrammingPython Programming

How to convert JSON into String?

import json
 
 
# list with dict a simple Json format
json_exp = \
    [{"id": "12", "name": "Mark"}, {"id": "13", "name": "Rock", "date": None}]
print(type(json_exp))
 
str_conv = json.dumps(json_exp)  # string
print(type(str_conv))
print(str_conv)
Sample output of above program.

class 'list'
class 'str'
[{"id": "12", "name": "Mark"}, {"id": "13", "name": "Rock", "date": null}]