Closed xxxserxxx closed 1 year ago
This report doesn't make sense to me. I am unable to reproduce any of the examples you pasted.
I am going to close this issue for now. Please feel free to post minimal reproduction examples, and we can reopen as needed.
There are two issues here. The bigger one is that yq doesn't understand :
ranges.
In jq, [1:3]
gives array items, indexed at 0, up to but not including item 3.
$ echo '["a","b","c","d","e","f"]' | jq -c '.[1:4]'
["b","c","d"]
yq does not understand :
. Construct an array with all of the children nodes of a
:
$ echo '<a><b/><b/><b/><b/></a>' | yq -p xml '.a[] | length'
4
$ echo '<a><b/><b/><b/><b/></a>' | yq -p xml '.a[1:3] | length'
0
$ echo '{"a": [{"b":0},{"b":0},{"b":0},{"b":0}]}' | jq '.a[1:3] | length'
2
Or, if you think the XML isn't an equavalent for the JSON, how about:
echo '<a><b>0<b/><b>0<b/><b>0<b/><b>0<b/></a>' | yq -p xml '.a[1:3] | length'
0
I can't find any case where yq understands :
. Can you?
The second issue, I can file a separate ticket for. The ;
is not a valid array character -- use it in an array index, and JQ throws an error. YQ silently swallows it, and generates some output.
I think you are confused. I am unable to reproduce any of your examples that involve yq.
The jq range array function
:
isn't supported (or doesn't get passed to jq):jq:
yq:
The
,
function works as in jq, and while;
is illegal in jq, yq accepts it without complaint and (from what I can see) causes any other index to be ignored:yq: