22
33* If you use Jsawk and want to help maintain it, please let me know and I'll add you to the repo.*
44
5- [ Updated underscore.js to v1.6.0 .] ( http://documentcloud.github.com/underscore/ )
5+ [ Updated underscore.js to v1.8.2 .] ( http://documentcloud.github.com/underscore/ )
66
77Jsawk is like awk, but for JSON. You work with an array of JSON objects
88read from stdin, filter them using JavaScript to produce a results array
@@ -18,10 +18,10 @@ increase your processing power, and other things.
1818[ This is a great blog post on setup and basic use of jsawk and resty, thanks
1919to @johnattebury .] ( http://johnattebury.com/blog/2011/06/spidermonkey-jsawk-resty-on-snow-leopard/ )
2020
21- You need to have the ` js ` interpreter installed. Your best bet is to navigate to
22- the mozilla site [ download and build the source] ( https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey )
21+ You need to have the ` js ` interpreter installed. Your best bet is to navigate to
22+ the mozilla site [ download and build the source] ( https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey )
2323based on the maintained documentation there.
24-
24+
2525Ready? Go.
2626
2727## Install
@@ -79,7 +79,7 @@ the resource.
7979
8080 -j <jsbin>
8181 Specify path to spidermonkey js binary.
82-
82+
8383 -n
8484 Suppress printing of JSON result set.
8585
@@ -90,7 +90,7 @@ the resource.
9090
9191 -s <string>
9292 Use `string` for input JSON instead of stdin.
93-
93+
9494 -v <name=value>
9595 Set global variable `name` to `value` in the script environment.
9696
@@ -303,7 +303,7 @@ JSON-to-JSON Transformations
303303
304304These examples transform the input JSON, modifying it and returning the
305305modified JSON as output on stdout to be piped elsewhere. Transformations of
306- this type are generally done with a script that follows one of these simple
306+ this type are generally done with a script that follows one of these simple
307307patterns:
308308
309309 1 . Modify the ` this ` object in place (no ` return ` statement necessary).
@@ -360,8 +360,8 @@ return value in the output set.
360360### JSON Grep: Select Certain Elements From Input ###
361361
362362Sometimes you want to use awk to select certain records from the input set,
363- leaving the rest unchanged. This is like the ` grep ` pattern of operation. In
364- this example we will extract all the records corresponding to people who are
363+ leaving the rest unchanged. This is like the ` grep ` pattern of operation. In
364+ this example we will extract all the records corresponding to people who are
365365over 30 years old.
366366
367367 cat /tmp/t | jsawk 'if (this.age <= 30) return null'
@@ -377,7 +377,7 @@ a whole, somewhat similar to the way aggregate functions like `SUM()` or
377377` COUNT() ` work in SQL. These types of operations fall under a few basic
378378patterns.
379379
380- 1 . Use a before script (` -b ` option) to do things to the JSON input before
380+ 1 . Use a before script (` -b ` option) to do things to the JSON input before
381381 transformations are done by the main script.
382382 2 . Use an after script (` -a ` option) to do things to the JSON result set
383383 after all transformations are completed by the main script.
@@ -430,7 +430,7 @@ alphabetically.
430430
431431Notice the use of JSONQuery to drill down into the JSON objects, an "after"
432432script to collate the results, and everything piped to the Unix ` sort `
433- tool to remove duplicate entries and do the lexical ordering. This is
433+ tool to remove duplicate entries and do the lexical ordering. This is
434434starting to show the power of the awk-like behavior now.
435435
436436### Return a Boolean Value
@@ -448,8 +448,8 @@ zero for success.
448448JSON Pretty-Printing
449449====================
450450
451- [ Resty] ( http://github.com/micha/resty ) includes the ` pp ` script that will
452- pretty-print JSON for you. You just need to install the JSON perl module
451+ [ Resty] ( http://github.com/micha/resty ) includes the ` pp ` script that will
452+ pretty-print JSON for you. You just need to install the JSON perl module
453453from CPAN. Use it like this:
454454
455455 GET /blogs.json | jsawk -q '..author' | pp
0 commit comments