Last Updated: October 13, 2016
·
60.85K
· k4ml

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)