mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Test negative indices in path expressions
This commit is contained in:
committed by
Nico Williams
parent
086a156ec3
commit
336c3deb8a
@@ -1002,6 +1002,28 @@ del(.[1], .[-6], .[2], .[-3:9])
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
[0, 3, 5, 6, 9]
|
||||
|
||||
# negative index
|
||||
setpath([-1]; 1)
|
||||
[0]
|
||||
[1]
|
||||
|
||||
pick(.a.b.c)
|
||||
null
|
||||
{"a":{"b":{"c":null}}}
|
||||
|
||||
pick(first)
|
||||
[1,2]
|
||||
[1]
|
||||
|
||||
pick(first|first)
|
||||
[[10,20],30]
|
||||
[[10]]
|
||||
|
||||
# negative indices in path expressions (since last/1 is .[-1])
|
||||
pick(last)
|
||||
[[10,20],30]
|
||||
[null,30]
|
||||
|
||||
#
|
||||
# Assignment
|
||||
#
|
||||
|
Reference in New Issue
Block a user