tidwall/jj

root array not working properly (# and -1)

kpym opened this issue · 1 comments

kpym commented

Consider the following json ["first","last"], we can access elements by positive index

> echo '["first","last"]' | jj 1
last

but we can't obtain the number of elements

> echo '["first","last"]' | jj # 
jj - JSON Stream Editor 1.2.3
missing required option: "keypath"
...

we can't access the last element (negative index)

> echo '["first","last"]' | jj -1 
jj - JSON Stream Editor 1.2.3
unknown option argument: "-1"
...

and we can't query with #[...] or #[...]#.

kpym commented

Sorry, it looks like quote the argument works

> echo '["first","last"]' | jj "#"
2
> echo '[1,2,3]' | jj "#[>1]#"
[2,3]

and using negative indexes is not possible anyway.