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)
Written by k4ml
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#