bizoo wrote:svenax wrote:However, the Python json parser does not allow for comments, which are used in most default files. To handle that, you need a custom decoder object.
I use this code:
- Code: Select all
RE_COMMENTS = re.compile('((//.*?$)|(/\*.*\*/))', re.M | re.S)
with open(keybindingfile) as f:
content = f.read()
keybindings = json.loads(RE_COMMENTS.sub('', content))
Ah yes, that should work. As long as you dont have text that looks like comments inside strings in the json file that is ...