7.0.2 • Published 10 years ago

jsontool v7.0.2

Weekly downloads
161
License
-
Repository
github
Last release
10 years ago

json is a fast CLI tool for working with JSON. It is a single-file node.js script with no external deps (other than node.js itself). A quick taste:

$ echo '{"foo":"bar"}' | json
{
  "foo": "bar"
}

$ echo '{"foo":"bar"}' | json foo
bar

$ echo '{"age":10}' | json -E 'this.age++'
{
  "age": 11
}

$ echo '{"latency":32,"req":"POST /widgets"},
{"latency":10,"req":"GET /ping"}
' | json -gaC 'this.latency > 10' req
POST /widgets

Features:

  • pretty-printing JSON
  • natural syntax (like JS code) for extracting particular values
  • get details on JSON syntax errors (handy for config files)
  • filter input JSON (see -E and -C options)
  • fast stream processing
  • JSON validation
  • in-place file editing

See http://trentm.com/json for full docs and examples as a man page.

Follow @trentmick for updates to jsontool.

Installation

  1. Get node.

  2. npm install -g jsontool (NOT npm install json, that's something else :|)

OR manually:

  1. Get the 'json' script and put it on your PATH somewhere (it is a single file with no external dependencies). For example:

     cd ~/bin
     curl -L https://github.com/trentm/json/raw/master/lib/jsontool.js > json
     chmod 755 json

You should now have "json" on your PATH:

$ json --version
json 7.0.0

WARNING for Ubuntu/Debian users: There is a current bug in Debian stable such that "apt-get install nodejs" installed a nodejs binary instead of a node binary. You'll either need to create a symlink for node, change the json command's shebang line to "#!/usr/bin/env nodejs" or use chrislea's PPA as discussed on issue #56.

Test suite

make test

You can also limit (somewhat) which tests are run with the TEST_ONLY envvar, e.g.:

cd test && TEST_ONLY=executable nodeunit test.js

I test against node 0.4 (less so now), 0.6, 0.8, and 0.10.

License

MIT (see the fine LICENSE.txt file).

Module Usage

Since v1.3.1 you can use "jsontool" as a node.js module:

var jsontool = require('jsontool');

However, so far the module API isn't that useful and the CLI is the primary focus.

Alternatives you might prefer

7.0.2

10 years ago

7.0.1

10 years ago

7.0.0

11 years ago

6.0.0

11 years ago

5.1.3

11 years ago

5.1.2

11 years ago

5.1.1

11 years ago

5.1.0

12 years ago

5.0.0

12 years ago

4.0.1

12 years ago

4.0.0

12 years ago

3.3.0

12 years ago

3.2.0

12 years ago

3.1.2

12 years ago

3.1.1

12 years ago

3.1.0

12 years ago

3.0.3

12 years ago

3.0.2

12 years ago

3.0.1

12 years ago

3.0.0

12 years ago

2.2.2

12 years ago

2.2.1

12 years ago

2.2.0

12 years ago

2.1.0

12 years ago

2.0.3

13 years ago

2.0.2

13 years ago

2.0.1

13 years ago

2.0.0

13 years ago

1.4.1

13 years ago

1.4.0

13 years ago

1.3.4

13 years ago

1.3.3

13 years ago

1.3.2

13 years ago

1.3.1

13 years ago

1.3.0

13 years ago