SublimePrettyJson
SublimePrettyJson copied to clipboard
support for c style comments
I know it's not something that is officially on www.json.org but it's a fairly common extension and many parsers allow comments and it would be nice if pretty json would allow them, too :)
maybe it could simply ignore stuff between /* */ ?
Hi @bastianhoyer
what can i do is to strip off comments to avoid getting exception on parsing json with comments, but in this case you will loose comments after prettyfing, so i really dont know if its worth implementing
import re
import json
comment_rx = re.compile(r"""
/\* .*? \*/ |
// [^\n\r]*
""",re.S | re.X)
s = """
{
/**dasfsd*/
"use_entire_file_if_no_selection" : true,
// test
// tedfsf
"indent" : 2,
"sort_keys" : false, // test
/*
* sdfadsf
*/
"ensure_ascii" : false
}
"""
s = comment_rx.sub('',s)
print(s)
print(json.dumps(json.loads(s)))
strips off all comments