UNPKG

26.3 kBMarkdownView Raw
1# json Changelog
2
3## not yet released
4
5(nothing yet)
6
7
8## 9.0.6
9
10- [issue #107] Fix man page installation with `npm install -g json`.
11
12
13## 9.0.5
14
15- [issue #112] Improve streaming (json -ga) performance for very long lines. For
16 example, using a 35 MB JSON object on one line gave a 50x speed improvement.
17 However, this is restricted to streaming of newline-separated JSON as opposed
18 to adjacent JSON objects not separated by newlines ({"a":1}{"a":2}). The
19 former case is expected to be much more common, and the latter may take a
20 slight performance hit from this change.
21
22## 9.0.4
23
24- [issue #108] Fix a crash on `json foo.bar` if "foo" is null.
25
26
27## 9.0.3
28
29- [issue #82] Fix a race in `-I/--in-place` temp file creation.
30 By https://github.com/inator
31
32
33## 9.0.2
34
35- [pull #72] Correct examples in docs for conditional filtering.
36
37
38## 9.0.1
39
40- [issue #71] Support `-o json-tab` and `-o jsony-tab` for TAB (i.e. `\t`)
41 indentation of emitted JSON.
42
43
44## 9.0.0
45
46- [issue #52] Fix termination on EPIPE in some cases.
47
48- Add `-0`, `-2`, `-4` options to more conveniently set the JSON indentation
49 without changing the mode.
50
51- [pull #64] Add `-M, --items` option for "itemizing" key/value pairs in an
52 object for easy iteration. For example:
53
54 $ echo '{"trent":{"age":38},
55 "ewan": {"age":4}}' | json -M
56 [
57 {
58 "key": "trent",
59 "value": {
60 "age": 38
61 }
62 },
63 {
64 "key": "ewan",
65 "value": {
66 "age": 4
67 }
68 }
69 ]
70
71 $ echo '{"trent":{"age":38},
72 "ewan": {"age":4}}' | json -Ma key value.age
73 trent 38
74 ewan 4
75
76 # List people that can vote.
77 $ echo '{"trent":{"age":38},
78 "ewan": {"age":4}}' | json -M -c 'this.value.age > 18' -a key
79 trent
80
81 Thanks to [AndrewO](https://github.com/AndrewO) for providing this!
82
83- **Backward incompatible change to `-c CODE` and `-e CODE`** changing their
84 implementation to use a JS function for processing rather than
85 `vm.runInNewContext`. This is the technique for which the `-C CODE` and `-E
86 CODE` options were added in version 7.0.0. Basically: This technique is
87 obviously better because it is 10x faster, so it is being made the only
88 supported way. `-C` and `-E`, then, become synonyms and may be removed
89 in a later release.
90
91 Unfortunately this does mean a few semantic differences in the `CODE`, the
92 most noticeable of which is that **`this` is required to access the object
93 fields:**
94
95 # Bad. Works with json < v9...
96 $ echo '{"green": "eggs"}' | json-v8 -e 'green="ham"'
97 {
98 "green": "ham"
99 }
100
101 # ... does *not* work with json v9.
102 $ echo '{"green": "eggs"}' | json -e 'green="ham"'
103 {
104 "green": "eggs"
105 }
106
107 # Good. Works with all versions of json.
108 $ echo '{"green": "eggs"}' | json -e 'this.green="ham"'
109 {
110 "green": "ham"
111 }
112
113 The old behaviour of `-c` and `-e` can be restored with the `JSON_EXEC=vm`
114 environment variable:
115
116 $ echo '{"green": "eggs"}' | JSON_EXEC=vm json -e 'green="ham"'
117 {
118 "green": "ham"
119 }
120
121 See the notes on [json 7.0.0](#json-700) below for full details on the
122 performance improvements and semantic changes.
123
124
125## 8.0.0
126
127- [pull #70] Move from 'jsontool' to 'json' in the npm registry! Thanks
128 to <https://github.com/zpoley> for graciously giving up the name, and to
129 @izs for driving. `npm install json` FTW. Here after `jsontool` will
130 stagnate at version 7.0.2.
131
132
133## 7.0.2
134
135- [issue #68] Fix `--keys, -k` handling in streaming mode, i.e. `json -gak`.
136
137
138## 7.0.1
139
140- [pull #60, issue #59] Fix not having a `json` on the PATH from
141 'npm install -g jsontool'.
142
143
144## 7.0.0
145
146- [issue #49] New `-C CODE` and `-E CODE` options to replace `-c CODE` and `-e
147 CODE`. The new options can be **10x or more faster**. An example processing
148 a large log of newline-separated JSON object as a stream:
149
150 $ ls -al big.log
151 -rw-r--r-- 1 trentm staff 156M Oct 25 23:31 big.log
152
153 $ time json -f big.log -gac 'this.audit' req.method req.url >/dev/null
154
155 real 0m21.380s
156 user 0m21.051s
157 sys 0m0.526s
158
159 $ time json -f big.log -gaC 'this.audit' req.method req.url >/dev/null
160
161 real 0m3.336s
162 user 0m3.124s
163 sys 0m0.295s
164
165 For comparison with `jq` (a C-based fast JSON processor tool):
166
167 $ time cat big.log | jq '.req.method, .req.url' >/dev/null
168
169 real 0m3.307s
170 user 0m3.249s
171 sys 0m0.136s
172
173 The speed difference in `json` is in how the given `CODE` is executed: the new
174 implementation uses a JS function, while the `-c/-e` options use node.js's
175 `vm.runInNewContext`. This change means some semantic changes to the given
176 `CODE`. Some examples to show the semantic differences:
177
178 1. `this` is required to access the object fields:
179
180 $ echo '{"foo": "bar"}' | json -e 'foo="baz"'
181 {
182 "foo": "baz"
183 }
184 $ echo '{"foo": "bar"}' | json -e 'this.foo="baz"'
185 {
186 "foo": "baz"
187 }
188
189 $ echo '{"foo": "bar"}' | json -E 'foo="baz"' # doesn't work
190 {
191 "foo": "bar"
192 }
193 $ echo '{"foo": "bar"}' | json -E 'this.foo="baz"'
194 {
195 "foo": "baz"
196 }
197
198 2. Explicit `return` is required with `-C` when using multiple statements:
199
200 $ echo '{"a": 2, "b": 6}' | json -C 'sum = this.a + this.b; sum > 5'
201
202 undefined:2
203 return (sum = this.a + this.b; sum > 5)
204 ^
205 SyntaxError: Unexpected token ;
206
207 $ echo '{"a": 2, "b": 6}' | json -C 'sum = this.a + this.b; return sum > 5'
208 {
209 "a": 2,
210 "b": 6
211 }
212
213 3. Some operations on the input object are more as you'd expect:
214
215 $ echo '["a", "b"]' | json -AE 'this.push("c")'
216 [
217 "a",
218 "b",
219 "c"
220 ]
221
222 $ echo '{"a":1,"b":2}' | json -E 'delete this.a'
223 {
224 "b": 2
225 }
226
227 4. `CODE` is no longer run in a sandbox, so you can shoot yourself in the
228 foot. Security warning: *Don't run untrusted code with '-E' or '-C'.*
229
230 $ echo '{}' | json -C 'process.stdout.end()'
231 [Error: process.stdout cannot be closed.]
232
233 $ echo '{}' | json -c 'process.stdout.end()'
234
235 vm.js:41
236 return ns[f].apply(ns, arguments);
237 ^
238 ReferenceError: process is not defined
239
240 Overall: (1) is a annoying, (2) is likely rare but at least is explicit,
241 (3) is a minor win, (4) is something to just be aware of. The major win is a
242 ~10x speed improvement!
243
244 See <https://github.com/nfitch/node-test/blob/master/test/vmalterns.js> for
245 analysis on the perf of various options for running user-given code. Thanks
246 to Nate for pushing me on this!
247
248- Major perf win on simple lookups, and with no behaviour change(!).
249 Similarly this was achieved by avoiding `vm.runInNewContext`:
250
251 $ time json6 -f big.log -ga time >/dev/null # v6
252
253 real 0m28.892s
254 user 0m26.839s
255 sys 0m2.295s
256
257 $ time json -f big.log -ga time >/dev/null # v7
258
259 real 0m2.427s
260 user 0m2.289s
261 sys 0m0.212s
262
263 The changes for this have changed `jsontool.parseLookup` and
264 `jsontool.handleLookup` incompatibly. However, using "jsontool.js" is
265 experimental and extremely rare. Please contact me if this impacts you.
266
267- Support for node 0.11.x -- basically stop using `util.puts`.
268
269 Note that apparently `vm.runInNewContext` has changed in node 0.11.x such
270 that the following no longer works:
271
272 $ echo '["a", "b"]' | json -A -e 'this[0]="A"'
273 [
274 "A",
275 "b"
276 ]
277
278 The result with node 0.11.x is actually:
279
280 $ echo '["a", "b"]' | json -A -e 'this[0]="A"'
281 [
282 "a",
283 "b"
284 ]
285
286 Using the new `-E` works:
287
288 $ echo '["a", "b"]' | json -A -E 'this[0]="A"'
289 [
290 "A",
291 "b"
292 ]
293
294 All the more reason to use the new `-E CODE`.
295
296- Change to 4-space indents. 'make check' clean. No functional change.
297
298- Include project url (and my name) in `json --version`. Also show *JSON*
299 formatted version info with `-j`. The point here isn't self-agrandization
300 but to help differentiate from the other `json` tool out there (`npm home
301 json`).
302
303 $ json --version
304 json 7.0.0
305 written by Trent Mick
306 https://github.com/trentm/json
307
308 $ json --version -j
309 {
310 "version": "7.0.0",
311 "author": "Trent Mick",
312 "project": "https://github.com/trentm/json"
313 }
314
315- Validation failures with a given filename will now show the filename, e.g.:
316
317 $ json -nf foo.json
318 json: error: "foo.json" is not JSON: Expected ',' instead of '"' at line 3, column 5:
319 "baz": "car"
320 ....^
321
322- Move json.1 to "man/man1" and set "directories.man" in package.json to
323 have "man json" work after "npm install -g jsontool" with the coming
324 npm 1.3.3 work.
325
326
327## 6.0.0
328
329- [Backwards incompatibility, issue #55] Drop support for grouping of adjacent
330 arrays (via `-g`, `--group`) **separated by no space**:
331
332 # Before
333 echo '["one"]["two"]' | json -g
334 [
335 "one",
336 "two"
337 ]
338
339 # After
340 $ echo '["one"]["two"]' | json -g
341 json: error: input is not JSON: Syntax error at line 1, column 8:
342 ["one"]["two"]
343 .......^
344 ["one"]["two"]
345
346 We still allow grouping of arrays separated by a newline:
347
348 # Before and after
349 $ echo '["one"]
350 ["two"]' | json -g
351 [
352 "one",
353 "two"
354 ]
355
356 This was dropped because the current regex technique used for grouping can
357 fail with a JSON string that contains ']['. Not worth it.
358
359- New `-I/--in-place` option for in-place editing of given files with:
360
361 $ cat foo.json
362 {"foo":1}
363
364 $ json -I -f foo.json # format the file
365 json: updated "foo.json" in-place
366 $ cat foo.json
367 {
368 "foo": 1
369 }
370
371 $ json -I -f foo.json -e 'this.bar=42' # add bar field
372 json: updated "foo.json" in-place
373 $ cat foo.json
374 {
375 "foo": 1,
376 "bar": 42
377 }
378
379 Note: I'd have loved to have used `-i` a la sed, but that is unfortunately
380 taken in this tool.
381
382
383## 5.1.3
384
385- Fix an issue with option parsing that resulted in this failing:
386
387 json -f foo.json -- -1.someKey
388
389
390
391## 5.1.2
392
393- [pull #43] Add '-n' as a short alias for '--validate'. (By Bill Pijewski,
394 github.com/pijewski).
395
396
397## 5.1.1
398
399- [issue #42] Fix an edge case where a blank line would be emitted for
400 `... | json -ga -c COND` where the `COND` resulted in no matches.
401- [issue #40] Improve "Lookups" section of docs to show how to lookup
402 non-identifier keys.
403
404
405## 5.1.0
406
407- [pull #39, issue #34] `json -ga` streams. (Largely by Fred Kuo, github.com/fkuo)
408 This means you can use `json` with an input stream of JSON objects. E.g.:
409
410 yes '{"foo":"bar"}' | json -ga
411
412 Limitations: As was already a limitation of the '-g' switch, this only
413 supports JSON objects delimited by newlines or with no space:
414
415 {"a":1}{"b":2} # good
416 {"a":1}\n{"b":2} # good
417 {"a":1} {"b":2} # bad
418
419 Additionally, currently only a stream of *objects* is supported, not
420 a stream of arrays. Such are the typical use cases I've encountered.
421
422
423## 5.0.0
424
425- [**backward incompatible**, issue #35] Special case the output for **a single
426 lookup AND JSON output** (i.e. `-j` or `-o json*`) to only output the value
427 instead of the more general array or table that is necessary for multiple
428 lookups. For objects:
429
430 # Before:
431 $ echo '{"one": "un", "two": "deux", "three": "troix"}' | json -j one
432 {
433 "one": "un"
434 }
435
436 # After:
437 $ echo '{"one": "un", "two": "deux", "three": "troix"}' | json -j one
438 "un"
439
440 # Unchanged:
441 $ echo '{"one": "un", "two": "deux", "three": "troix"}' | json -j one two
442 {
443 "one": "un",
444 "two": "deux"
445 }
446
447 For arrays:
448
449 # Before:
450 $ echo '["a", "b", "c"]' | json -j 0
451 [
452 "a"
453 ]
454
455 # After:
456 $ echo '["a", "b", "c"]' | json -j 0
457 "a"
458
459 # Unchanged:
460 $ echo '["a", "b", "c"]' | json -j 0 1
461 [
462 "a",
463 "b"
464 ]
465
466 The motivation for this change was (a) the WTF of the first example above and
467 (b) issue #36 where one could no longer extract a single value using '-j' to
468 explicitly get JSON string quoting.
469
470
471
472## 4.0.1
473
474- [issue #36] Turn off coloring for inspect output (`json -i`, `json -o
475 inspect`) if stdout is not a TTY.
476
477
478## 4.0.0
479
480- Add `--validate` option to just validate (no processing and output)
481
482 $ echo '{"foo" "bar"}' | json
483 json: error: input is not JSON: Expected ':' instead of '"' at line 1, column 8:
484 {"foo" "bar"}
485 .......^
486 {"foo" "bar"}
487 $ echo '{"foo" "bar"}' | json --validate
488 json: error: input is not JSON: Expected ':' instead of '"' at line 1, column 8:
489 {"foo" "bar"}
490 .......^
491 $ echo '{"foo" "bar"}' | json --validate -q
492 $ echo $?
493 1
494
495- Add `-f FILE` option for specifying an input file (or files) instead of
496 stdin:
497
498 $ json -f foo.json
499 {
500 "foo": "bar"
501 }
502 $ json -f foo.json foo
503 bar
504
505- [Backward incompatible] Move "auto-arrayification" to require explicitly
506 using the "-g" or "--group" option:
507
508 $ echo '{"one":"two"}{"three":"four"}' | json
509 json: error: input is not JSON: Syntax error at line 1, column 14:
510 {"one":"two"}{"three":"four"}
511 .............^
512 {"one":"two"}{"three":"four"}
513 $ echo '{"one":"two"}{"three":"four"}' | json -g -o json-0
514 [{"one":"two"},{"three":"four"}]
515
516 This is to avoid auto-arrayification accidentally making an invalid JSON
517 object (with a missing comma) be transformed to a valid array:
518
519 $ cat oops.json
520 {
521 "a": {
522 "b": [
523 {"foo": "bar"}
524 {"foo": "bar"}
525 ]
526 }
527 }
528 $ cat oops.json | json3 -o json-0
529 [{"a":{"b":[{"foo":"bar"},{"foo":"bar"}]}}]
530
531 Basically the jusitification for this breaking change is that the
532 invariant of `json` validating the input JSON is more important than the
533 occassional convenience of grouping.
534
535- Use 8 space indent for syntax error message on stderr instead of '\t'.
536 Minor change. Tabs are evil.
537
538
539## 3.3.0
540
541- Add `-k|--keys` option to output the input objects keys:
542
543 $ echo '{"name": "trent", "age": 38}' | json -k
544 [
545 "name",
546 "age"
547 ]
548 $ echo '{"name": "trent", "age": 38}' | json -ka
549 name
550 age
551
552- Drop jsontool v2 dependency. This had been added for the first few json3
553 releases to provide a `json2` for comparison. `json` v3 is fairing well
554 enough now to not bother.
555
556
557## 3.2.0
558
559- Support negative array indeces (a la Python list indeces), e.g.:
560
561 $ echo '["a", "b", "c"]' | json -- -1
562 c
563
564
565## 3.1.2
566
567- Update man page and move bulk examples from README to man page. Use ronn (the
568 ruby one) instead of ronnjs: better and more reliable formatting. Add 'make
569 docs' and 'make publish' (the latter to push to GH pages at
570 <http://trentm.com/json>).
571- [issue #31] Fix error message for `json -o`.
572
573
574## 3.1.1
575
576- [issue #32] Fix '-D' option processing so `json -D/` works (no space).
577
578
579## 3.1.0
580
581- [pull #29] Add '-D' option to set a delimiter for lookups (default is '.'),
582 so that this example works:
583
584 $ echo '{"a.b": {"b": 1}}' | json -D / a.b/b
585 1
586
587 By Yaniv Aknin.
588
589
590## 3.0.3
591
592- [issue #30] Fix lookup strings with multiple double-quotes.
593- [issue #28] Don't error on a multi-level lookup where one of the components
594 is undefined. E.g., the following is no longer an error:
595
596 $ echo '{"foo": "bar"}' | json not_foo.bar
597
598
599## 3.0.2
600
601- [issue #27] Fix issue handling multi-level lookups (e.g. 'json foo.bar').
602
603
604## 3.0.1
605
606- Fix a bogus 'json' dep.
607
608
609## 3.0.0
610
611- Switched to json 3.x dev on master. "2.x" branch created for any
612 necessary 2.x releases. See the
613 [2.x changelog here](https://github.com/trentm/json/blob/2.x/CHANGES.md).
614
615- [Backward incompatible] A significant change to 'jsony' default output and
616 some use cases to increase utility. These changes necessitated a few
617 backward incompatible changes. However, care was take to only break
618 compat for (a) rare use cases and (b) where utility was much improved.
619 See <https://github.com/trentm/json/wiki/backward-incompat-json-3-changes>
620 for full details of backward incompatible changes.
621
622- New "conditional filtering" via the `-c CODE` option. If the input is an
623 array, then `-c` will automatically switch to processing each element
624 of the array. Example:
625
626 $ echo '[{"name":"trent", "age":38}, {"name":"ewan", "age":4}]' \
627 | json3 -c 'age>21'
628 [
629 {
630 "name": "trent",
631 "age": 38
632 }
633 ]
634
635- Change `-e CODE` option to automatically switch to array processing if
636 the input is an array. This matches the behaviour of the new `-c CODE`
637 option. Example:
638
639 $ echo '[{"name":"trent", "age":38}, {"name":"ewan", "age":4}]' \
640 | json3 -e 'age++' -o json-0
641 [{"name":"trent","age":39},{"name":"ewan","age":5}]
642
643- New '-A' option to force `-e` and `-c` to process an input array as a
644 single item.
645
646- Add [ansidiff](https://github.com/trentm/ansidiff)-based colored diffs
647 for test suite failures.
648
649- [issue #26] Add support for escapes in the delimiter given by `-d DELIM`:
650
651 $ echo '[{"one":"un","two":"deux"},{"one":"uno","two":"dos"}]' \
652 | json -a -d'\t' one two
653 un deux
654 uno dos
655
656
657## 2.2.1
658
659- Hack workaround for issue #24 to not get a spurious "process.stdout cannot be
660 closed" from current node 0.6 versions. Note: currently this guard is only
661 applied for node v0.6.0..v0.6.8 inclusive.
662
663
664## 2.2.0
665
666- New "-e CODE" option to execute the given code on the input object; or,
667 if '-a/--array' is given, then on each item in the input array. Execution
668 is done before filtering.
669
670 $ echo '{"age": 38}' | json -e 'this.age++'
671 {
672 "age": 39
673 }
674
675
676## 2.1.0
677
678- Improve error message when input is not JSON to include context and line
679 and column position. This is implemented using a JSON parser from
680 (<https://github.com/douglascrockford/JSON-js>). Example:
681
682 $ echo "[1,,2]" | json
683 json: error: input is not JSON: Unexpected ',' at line 1, column 4:
684 [1,,2]
685 ...^
686 [1,,2]
687
688
689## 2.0.3
690
691- Auto-arrayification: Drop support for arrayifying an array adjacent to
692 an object. I.e. only arrayify adjacent objects *or* adjacent arrays.
693
694- Auto-arrayification: Change "arrayification" of adjacent *arrays* to be
695 a single flat arrays of the input arrays' elements. Before:
696
697 $ echo '[1,2][3,4]' | bin/json
698 [
699 [
700 1,
701 2,
702 ],
703 [
704 3,
705 4
706 ]
707 ]
708
709 and now:
710
711 $ echo '[1,2][3,4]' | bin/json
712 [
713 1,
714 2,
715 3,
716 4
717 ]
718
719 This is expected to be more useful in practice.
720
721- Auto-arrayification: Allow JSON objects (or arrays) to be "arrayified"
722 if not separated by any space. Previously a newline (at least) separation
723 was required. So, for example, the following now works:
724
725 $ echo '{"a":1}{"b":2}' | bin/json -o json-0
726 [{"a":1},{"b":2}]
727
728 The rules for auto-arrayification then are: Objects and arrays only,
729 separated by no space or space including a newline.
730
731- Fix stdout flushing in some cases.
732
733
734## 2.0.2
735
736- Add node v0.6 support. Drop v0.2 and v0.3 support.
737
738
739## 2.0.1
740
741- [issue#23] Fix output in '-a|--array' mode if one or more keys don't
742 exist in one or more of the array items.
743
744
745## 2.0.0
746
747- '-o | --output MODE' support. Supported modes:
748
749 jsony (default): JSON with string quotes elided
750 json: JSON output, 2-space indent
751 json-N: JSON output, N-space indent, e.g. 'json-4'
752 inspect: node.js `util.inspect` output
753
754- '-a|--array' for independently processing each element of an input array.
755
756 $ echo '[
757 {
758 "name": "Trent",
759 "id": 12,
760 "email": "trent@example.com"
761 },
762 {
763 "name": "Mark",
764 "id": 13,
765 "email": "mark@example.com"
766 }
767 ]' | json -a name email
768 Trent trent@example.com
769 Mark mark@example.com
770
771 This example shows that '-a' results in tabular output. The '-d' option
772 can be used to specify a delimiter other than the default single space, e.g.:
773
774 json -d, -a field1 field2
775
776 [Backward Incompatibility] This is a replacement for the experimental '*'
777 syntax in the lookup strings (previously enabled via '-x|--experimental').
778 That syntax and option has been removed.
779
780- Add '--' option processing support and error out if an unknown option is
781 given.
782
783- Support multiple top-level JSON objects as input to mean a list of
784 these object:
785
786 $ echo '{"one": 1}
787 {"two": 1}' | ./lib/jsontool.js
788 [
789 {
790 "one": 1
791 },
792 {
793 "two": 1
794 }
795 ]
796
797 This can be nice to process a stream of JSON objects generated from
798 multiple calls to another tool or `cat *.json | json`. Rules:
799
800 - Only JS objects and arrays. Don't see strong need for basic
801 JS types right now and this limitation simplifies.
802 - The break between JS objects has to include a newline. I.e. good:
803
804 {"one": 1}
805 {"two": 2}
806
807 bad:
808
809 {"one": 1}{"two": 2}
810
811 This condition should be fine for typical use cases and ensures
812 no false matches inside JS strings.
813
814
815## 1.4.1
816
817- [issue #9] Gracefully handle EPIPE (i.e. stdout being closed on json before
818 it is finished writing).
819
820
821## 1.4.0
822
823- [issue #19] Allow multiple lookup arguments:
824
825 $ echo '{"one": 1, "two": 2}' | json one two
826 1
827 2
828
829 WARNING: This involve a backward incompatible change in the JS APIs
830 `jsontool.processDatum` and `jsontool.processDatumExperimental`.
831
832
833## 1.3.4
834
835- [issue #18] Fix `json --version` for standalone mode again (was broken in json 1.3.3).
836
837
838## 1.3.3
839
840- WARNING: `json --version` is broken when running outside the source (or npm
841 install'd) tree. I.e. this is a bad release for standalone.
842- [issue #17] Ensure stdout is flushed on exit.
843
844
845## 1.3.2
846
847- [issue #16] Fix to use `<regex object>.exec` instead of using the regex
848 object as a function -- no longer allowed in the v8 used in node v0.5.x.
849
850
851## 1.3.1
852
853- Make "jsontool" require'able as a module. For example, you can now:
854
855 $ npm install jsontool
856 $ node
857 > var jsontool = require('jsontool')
858 > jsontool.parseLookup('a.b.c')
859 [ 'a', 'b', 'c' ]
860 > jsontool.parseLookup('my-key.0["bar"]')
861 [ 'my-key', '0', '["bar"]' ]
862 > jsontool.main(['', '', '--help'])
863 Usage: <something generating JSON on stdout> | json [options] [lookup]
864 ...
865
866 Currently other exported API is experimental and will likely change to be
867 more generally useful (e.g. the current `processDatum` isn't all handy
868 for module usage).
869
870 Note: For command-line usage, the main module has moved from "json" to
871 "lib/jsontool.js". So, if you are not using npm, you can setup the `json`
872 command via something like:
873
874 alias json='.../json/lib/jsontool.js'
875
876
877## 1.3.0
878
879- package.json and publish to npm as "jsontool" ("json" name is taken)
880- Add experimental support for '*' in the lookup. This will extract all
881 the elements of an array. Examples:
882
883 $ echo '["a", "b", "c"]' | json -x '*'
884 a
885 b
886 c
887 $ echo '[{"one": "un"}, {"two": "deux"}]' | json -x '*'
888 {
889 "one": "un"
890 }
891 {
892 "two": "deux"
893 }
894 $ echo '[{"foo": "bar"}, {"foo": "baz"}]' | json -x '*.foo'
895 bar
896 baz
897
898 This is still experimental because I want to feel it out (is it useful?
899 does it cause problems for regular usage?) and it is incomplete. The
900 second example above shows that with '\*', json can emit multiple JSON
901 documents. `json` needs to change to support *accepting* multiple JSON
902 documents.
903
904 Also, a limitation: How to extract *multiple* fields from a list of
905 objects? Is this even a necessary feature? Thinking out loud:
906
907 '*.{name,version}' # a la bash. Josh likes it. What else do you need?
908
909- Add '-x|--experimental' option to turn on incomplete/experimental features.
910
911
912## 1.2.1
913
914- [issue #12] Fix handling of output when result of lookup is `undefined`.
915
916
917## 1.2.0
918
919- [issue #10] Fix for node v0.5.
920
921
922## 1.1.9
923
924- [Issue 8] Don't emit a newline for empty output.
925
926
927## 1.1.8
928
929- [Issue 7] Handle "HTTP/1.1 100 Continue" leading header block.
930- [Issue 4] Add a man page (using ronnjs).
931
932
933## 1.1.7
934
935- [Issue 5] Fix getting a key with a period. E.g.:
936
937 echo '{"foo.bar": 42}' | json '["foo.bar"]'
938
939 `json` is now doing much better lookup string parsing. Because escapes are
940 now handled properly you can do the equivalent a little more easily:
941
942 $ echo '{"foo.bar": 42}' | json foo\\.bar
943 42
944
945
946## 1.1.6
947
948- [Issue 6] Error exit value if invalid JSON.
949
950
951## 1.1.4
952
953- [Issue 2] Fix bracket notation: `echo '{"foo-bar": "baz"}' | json '["foo-bar"]'`
954
955
956(Started maintaining this log 19 March 2011. For earlier change information
957you'll have to dig into the commit history.)