From a45c937f80dd93a298d7baf0947385db9f3032dc Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Wed, 5 Feb 2014 15:23:32 -0600 Subject: [PATCH] #285 add and builtins --- builtin.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin.c b/builtin.c index 087741fa..f5c48a6a 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\");", };