i have normal string it come without quote for columns name and when i try to loaded as json it give error because there are no quotes for the columns inside the string , is there are a way in python i can add the double quotes to columns name inside string so i can get valid json formate ?
below is sample if the string :
string_data = '{name: John, age: 30, city: New York}'
json_data = json.loads(string_data)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 380, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 1 column 2 (char 1)
i need a way to dynamically add the quotes for columns names so i can get valid json formate before i call json.load function
2