diff options
author | Laurent Arnoud <laurent@spkdev.net> | 2010-10-08 23:59:16 +0200 |
---|---|---|
committer | Laurent Arnoud <laurent@spkdev.net> | 2010-10-09 00:00:09 +0200 |
commit | 0d8c191b4fab5d87f71f3d9e9b2b1269a8e618b8 (patch) | |
tree | b2ccc06b0f18b97d132c49d10b2ef0237d821b3e | |
parent | e22b2f2bdfe6a9b0c6133a206963e645ff389ff5 (diff) | |
download | json-0d8c191b4fab5d87f71f3d9e9b2b1269a8e618b8.tar.gz |
bin/prettify_json.rb: Set max_nesting and create_additions to false like edit_json
it refers to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=561839
Signed-off-by: Laurent Arnoud <laurent@spkdev.net>
-rwxr-xr-x | bin/prettify_json.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/bin/prettify_json.rb b/bin/prettify_json.rb index 5e1f806..943546f 100755 --- a/bin/prettify_json.rb +++ b/bin/prettify_json.rb @@ -53,18 +53,21 @@ EOT end filename = nil -json = JSON[ - if args.empty? - STDIN.read - else - File.read filename = args.first - end -] +str = nil +json_opts = {:max_nesting => false, :create_additions => false} + +if args.empty? + str = STDIN.read +else + str = File.read(filename = args.first) +end + +json = JSON[str, json_opts] output = if opts['s'] - JSON.fast_generate json + JSON.fast_generate json, json_opts else # default is -l - JSON.pretty_generate json + JSON.pretty_generate json, json_opts end if opts['i'] && filename |