In this Python string tutorial, you will learn how to convert string to JSON in Python.
# Import json module import json # Create a string S = '{"website": "AiHints", "articles": 200}' # Convert string into json J = json.loads(S) # Print json print(J) # Save the json file with open('website.json', 'w') as f: json.dump(J, f)
Output:
{'website': 'AiHints', 'articles': 200}