From 68f41097b983e057240b68d62ecf8f09c6d2df36 Mon Sep 17 00:00:00 2001 From: Santiago Lapresta Date: Mon, 10 Mar 2014 01:35:44 +0100 Subject: [PATCH] Added `arrays` and other filters Arrays, objects, numbers, strings, booleans, nulls, values (non-nulls) -- these builtins filter out those inputs that don't match the name of the builtin. This fixes #322 and #324. --- builtin.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/builtin.c b/builtin.c index 9881dc1c..da766e16 100644 --- a/builtin.c +++ b/builtin.c @@ -683,6 +683,14 @@ static const char* const jq_builtins[] = { "def leaf_paths: . as $dot|paths|select(. as $p|$dot|getpath($p)|type|. != \"array\" and . != \"object\");", "def any: reduce .[] as $i (false; . or $i);", "def all: reduce .[] as $i (true; . and $i);", + "def arrays: select(type == \"array\");", + "def objects: select(type == \"object\");", + "def iterables: arrays, objects;", + "def booleans: select(type == \"boolean\");", + "def numbers: select(type == \"number\");", + "def strings: select(type == \"string\");", + "def nulls: select(type == \"null\");", + "def values: arrays, objects, booleans, numbers, strings;", }; #undef LIBM_DD