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:
pkoppstein authored and Nico Williams committed 2023-07-05 23:48:31 -05:00
1 parent a881532b29
commit 416e8ada7d
3 files changed
+32

No files matched your search

+8
View File
@@ -219,6 +219,14 @@ map_values(.+1)
{"a": 1, "b": 2, "c": 3}
{"a": 2, "b": 3, "c": 4}
pick(.a, .b.c, .x)
{"a": 1, "b": {"c": 2, "d": 3}, "e": 4}
{"a":1,"b":{"c":2},"x":null}
[1,2,3,4] | pick(.[2], .[0], .[0])
[1,2,3,4]
[1,null,3]
path(.a[0].b)
null
["a",0,"b"]