summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris West <solo-github@goeswhere.com>2015-10-03 14:44:10 +0100
committerChris West <solo-github@goeswhere.com>2015-10-03 14:44:10 +0100
commitdf4a67cc17a0709a0312153c583dcd49c16f3147 (patch)
treed2620e5d11305c0e32043a7386074761a2d4f9e1
parentb820574f26d8064bd5424e89d7c04a6559afa17a (diff)
parent505270162406fe5982732268c2a031ba361cd2c0 (diff)
downloadghetto-json-df4a67cc17a0709a0312153c583dcd49c16f3147.tar.gz
ghetto-json-df4a67cc17a0709a0312153c583dcd49c16f3147.tar.bz2
ghetto-json-df4a67cc17a0709a0312153c583dcd49c16f3147.tar.xz
ghetto-json-df4a67cc17a0709a0312153c583dcd49c16f3147.zip
Merge pull request #1 from jotham/master
Added support for // style comments in JSON if commentjson is installed.
-rwxr-xr-xghetto_json7
1 files changed, 6 insertions, 1 deletions
diff --git a/ghetto_json b/ghetto_json
index 075accb..60d8542 100755
--- a/ghetto_json
+++ b/ghetto_json
@@ -4,6 +4,11 @@ import json
import sys
import shlex
+try:
+ import commentjson
+ json_load = commentjson.load
+except ImportError:
+ json_load = json.load
def main(params_list):
params = dict(x.split("=", 2) for x in params_list)
@@ -11,7 +16,7 @@ def main(params_list):
changed = False
with open(path) as f:
- obj = json.load(f)
+ obj = json_load(f)
for (key, target) in params.items():
parts = key.split('.')
ref = obj