`.[]` doesn't work as expected
pkoppstein opened this issue · comments
The README indicates that .[] has been implemented, but the following queries both fail using query-json (version 0.5.20):
$ jq '.[0,1]' <<< [1,2,3]
1
2
$ jq '.[]' <<< [1,2,3]
1
2
3
$
p.s. Is this project still alive?
Hi @pkoppstein
.[]
is equivalent as . | .map
so probably doable with a workaround. If .[]
isn't working as expected, can you give me an example? If it doesn't work it might be a bug.
Array index access work great:
q '.[1]' --kind=inline '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]'
Regarding your question about the "liveness" of this project:
I'm not entirely sure what's death or alive, works great for my usage and isn't complete. You can use it if you want, you can submit a PR/issues and will get merged/fixed.
@davesnx - Thanks for your response. The two examples I gave in my initial post show the two queries of interest together with the actual output produced by jq, which is of course in each case also the correct/expected output.
Regarding .map
:
query-json '.map' <<< [1,2,3]
produces: [1, 2, 3]
which has nothing to do with the expected output from .[]
.
Please also note that your response does not address the second issue regarding .[E]
when E is a stream.