builtin: add pick(stream)
pick(stream) works on both arrays and objects Restrictions on the dot-paths are specified in manual.yml See #2578
This commit is contained in:
1 parent
a881532b29
commit
416e8ada7d
3 files changed
+32
No files matched your search
@@ -260,6 +260,12 @@ def walk(f):
|
||||
else f
|
||||
end;
|
||||
|
||||
# stream should be a stream of dot-paths
|
||||
def pick(stream):
|
||||
. as $in
|
||||
| reduce path(stream) as $a (null;
|
||||
setpath($a; $in|getpath($a)) );
|
||||
|
||||
# SQL-ish operators here:
|
||||
def INDEX(stream; idx_expr):
|
||||
reduce stream as $row ({}; .[$row|idx_expr|tostring] = $row);
|
||||
|
||||
Reference in new issue
Block a user