Sha256: 1242bf9ee03e369f38a8dd9574ce4b3814768a23ed3f3b793cc9b36ec8dd5caa

Contents?: true

Size: 900 Bytes

Versions: 162

Compression:

Stored size: 900 Bytes

Contents

r"""Command-line tool to validate and pretty-print JSON

Usage::

    $ echo '{"json":"obj"}' | python -m simplejson.tool
    {
        "json": "obj"
    }
    $ echo '{ 1.2:3.4}' | python -m simplejson.tool
    Expecting property name: line 1 column 2 (char 2)

"""
import sys
import simplejson

def main():
    if len(sys.argv) == 1:
        infile = sys.stdin
        outfile = sys.stdout
    elif len(sys.argv) == 2:
        infile = open(sys.argv[1], 'rb')
        outfile = sys.stdout
    elif len(sys.argv) == 3:
        infile = open(sys.argv[1], 'rb')
        outfile = open(sys.argv[2], 'wb')
    else:
        raise SystemExit(sys.argv[0] + " [infile [outfile]]")
    try:
        obj = simplejson.load(infile)
    except ValueError, e:
        raise SystemExit(e)
    simplejson.dump(obj, outfile, sort_keys=True, indent=4)
    outfile.write('\n')


if __name__ == '__main__':
    main()

Version data entries

162 entries across 162 versions & 1 rubygems

Version Path
chef-16.18.30-universal-mingw32 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.18.30 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.18.0-universal-mingw32 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.18.0 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.17.51-universal-mingw32 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.17.51 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.17.39-universal-mingw32 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.17.39 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.17.18-universal-mingw32 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.17.18 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.17.4-universal-mingw32 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.17.4 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.16.13-universal-mingw32 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.16.13 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.16.7-universal-mingw32 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.16.7 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.15.22-universal-mingw32 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.15.22 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.14.1-universal-mingw32 lib/chef/provider/package/yum/simplejson/tool.py
chef-16.14.1 lib/chef/provider/package/yum/simplejson/tool.py