From: Nicolas Williams Date: Wed, 5 Feb 2014 21:23:32 +0000 (-0600) Subject: #285 add and builtins X-Git-Tag: jq-1.4~45 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a45c937f80dd93a298d7baf0947385db9f3032dc;p=jq #285 add and builtins --- diff --git a/builtin.c b/builtin.c index 087741f..f5c48a6 100644 --- a/builtin.c +++ b/builtin.c @@ -678,6 +678,8 @@ static const char* const jq_builtins[] = { "def reverse: [.[length - 1 - range(0;length)]];", "def index(i): .[i][0];", "def rindex(i): .[i][-1:][0];", + "def paths: path(recurse(if (type|. == \"array\" or . == \"object\") then .[] else empty end))|select(length > 0);", + "def leaf_paths: . as $dot|paths|select(. as $p|$dot|getpath($p)|type|. == \"array\" or . == \"object\");", };