hvqbpg
Last Updated: October 13, 2016
·
1.534K
· k4ml
Dab3052b18c86b0884341d9c2c67a4f3

Parse 'json' with single quotes in python

Sometimes, you may got this:-

data = "{'name': 'kamal', 'address': 'jb'}"

but json.loads(data) would refuse this as json require double quotes. You can use ast.literal_eval() instead.

data_dict = ast.literal_eval(data)
Say Thanks
Respond