In this video, we will write a python program to convert a string to JSON.
In the video, we have used the following approaches to convert from string to JSON:
1. Using json.loads()
2. Using eval()
Method 1: Using json.loads(): In this method, first we create a python dictionary with some values. Then we convert the dictionary to
JSON serializable format using json.dumps(). Then we pass the output of the json.dumps() into the json.loads() function to get the required JSON.
Method 2: Using eval(): In this method, we need to pass a string form of a Python dictionary. Python eval() function will convert the string to Python dict() type. The result from the eval() function will be our required JSON or dict object.
Python | Ways to convert string to json object: https://www.geeksforgeeks.org/python-ways-to-convert-string-to-json-object/