Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

How can I put integer as an argument in jq?

$
0
0

I have been trying to use jq to parse a json file returned from the aws cli, but I'm stuck with the problem of referencing an array using the index number. I need to do this because I want to export a text file describing the security groups in a specific format, including all the inbound and outbound rules.

for (( i=1; i<=groupCount; i++ )) ; do    echo $i    echo $(echo "$input" | jq --arg i $i '.SecurityGroups[$i]')done

This returns an error:

1jq: error (at <stdin>:189): Cannot index array with string "1"2jq: error (at <stdin>:189): Cannot index array with string "2"3jq: error (at <stdin>:189): Cannot index array with string "3"

Is there any way around this?


Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>