import json
old = str({"1": "red", "2": "black", "3": "green"})
new = json.loads(old)
{'1': 'red', '2': 'black', '3': 'green'}
import json
with open('data.txt') as file:
data = file.read()
json_data = json.loads(data)
print(type(json_data))
print(json_data)
<class 'dict'>
{'1': 'red', '2': 'black', '3': 'green'}
import json
old = json.dumps({"1": "red", "2": "black", "3": "green"}, indent = 4)
new = json.loads(old)
print(new['1'])