]> granicus.if.org Git - jq/commit
Add `?`, `.[]?`, and `..` operators 298/head
authorNicolas Williams <nico@cryptonector.com>
Mon, 17 Feb 2014 18:28:26 +0000 (12:28 -0600)
committerNicolas Williams <nico@cryptonector.com>
Thu, 20 Feb 2014 21:33:07 +0000 (15:33 -0600)
commitfe29d3d3fa4a147a5103f314bc09287c4c32a81d
tree0f4d4c5625016c2631cf6b101436bb8d11bb8501
parent3d33412e9a88f86510b2dc8afe6ac4e82b1a44df
Add `?`, `.[]?`, and `..` operators

Make XPath-like `//a/b` recursive structure traversal easier in jq,
which then becomes:

    ..|.a?.b?

The `?` operator suppresses errors about . not being an array or object.
The `..` operator is equivalent to calling the new `recurse_down`
built-in, which in turn is equivalent to

    recurse(.[]?)

Note that `..a` is not supported; neither is `...a`.  That could be add
added, but it doesn't seem worth the trouble of saving the need to type
a '|'.
builtin.c
docs/content/3.manual/manual.yml
execute.c
lexer.l
opcode_list.h
parser.y
tests/all.test