diff options
author | Jotham Read <jotham.read@gmail.com> | 2015-10-02 21:41:35 +1300 |
---|---|---|
committer | Jotham Read <jotham.read@gmail.com> | 2015-10-02 21:41:35 +1300 |
commit | 505270162406fe5982732268c2a031ba361cd2c0 (patch) | |
tree | d2620e5d11305c0e32043a7386074761a2d4f9e1 | |
parent | b820574f26d8064bd5424e89d7c04a6559afa17a (diff) | |
download | ghetto-json-505270162406fe5982732268c2a031ba361cd2c0.tar.gz ghetto-json-505270162406fe5982732268c2a031ba361cd2c0.tar.bz2 ghetto-json-505270162406fe5982732268c2a031ba361cd2c0.tar.xz ghetto-json-505270162406fe5982732268c2a031ba361cd2c0.zip |
Update ghetto_json
Added support for // style comments in JSON if commentjson is installed.
-rwxr-xr-x | ghetto_json | 7 |
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 |