I have a very large JSON-like file, but it is not using proper JSON syntax: the object keys are not quoted. I\'d like to write a script to fix the file, so that I can load
I suggest matching whole words that are not enclosed into double quotation marks and adding quotation marks around them:
import re p = re.compile(r'(?"', test_str)
See IDEONE demo, output:
{"abc" : "xyz", "cde" : {}, "fgh" : ["hfz"]}