Using comments in JSON configuration files in Sublime Text can make JSON objects unable to be decoded.Here is my story:
I newly installed SublimeREPL plugin in my Sublime Text 3. Soon I discovered it ran Python2.7 instead of 3.5 in default, so I added my own Python3.5 configuration files according to SublimeREPL Docs to make it support Python3.5.
My Packages/SublimeREPL/config/Python3.5/Main.sublime-menu JSON config file looks like this:
[
{
“id”: “tools”,
“children”:
[{
“caption”: “SublimeREPL”,
“mnemonic”: “R”,
“id”: “SublimeREPL”,
“children”:
[
{“caption”: “Python3.5”,
“id”: “Python3.5”,
"children":[
{"command": "repl_open",
"caption": "Python3.5",
"id": "repl_python3.5",
"mnemonic": "P",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python3", "-i", "-u"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python3",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
},
// run files
{"command": "repl_open",
"caption": "Python3.5 - RUN current file",
"id": "repl_python3.5_run",
"mnemonic": "R",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python3", "-u", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python3",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
]}
]
}]
}
]
Note there is a comment // run files in this file. This config works fine from the menu bar tools->SublimeREPL->Python3.5. However,when I tried to bind the F5 key with repl_python3.5_run to make it easier access to 3.5,the following exception was thrown in the console:
After I removed the // run files comment. The F5 key works fine.It’s exactly the comment that cause the problem. Sublime Text uses JSON as config files,lots of config files come with // style comments. As we all know, comments were removed from JSON by design.
Then how can sublime text allow comments in config files,is it using a pipe? If it is, how can my key binding fail?