This will most likely not work everywhere, but in the beginning, here is a simple regular expression that needs to convert keys to quoted strings so you can go to json.loads. Or is that what you are already doing?
In[70] : quote_keys_regex = r'([\{\s,])(\w+)(:)' In[71] : re.sub(quote_keys_regex, r'\1"\2"\3', js_obj) Out[71]: '{"x":1, "y":2, "z":3}' In[72] : js_obj_2 = '{x:1, y:2, z:{k:3,j:2}}' Int[73]: re.sub(quote_keys_regex, r'\1"\2"\3', js_obj_2) Out[73]: '{"x":1, "y":2, "z":{"k":3,"j":2}}'
source share