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

How to iterate over JSON array with jq?

$
0
0

I'm building a script to download all CodeCommit repositories at once.

REPOS=$(aws codecommit list-repositories)echo $REPOS | jq -r '.[]' | while read name ; do    git clone XXXdone

In first line I get all repos JSON like this:

[  {"repositoryName": "repo_a","repositoryId": "XXXXXX"  },  {"repositoryName": "repo_b","repositoryId": "XXXXXX"  },  {"repositoryName": "repo_c","repositoryId": "XXXXXX"  },  {"repositoryName": "repo_d","repositoryId": "XXXXXX"  }]

I need simple iterate this json, to get attributes repositoryName and execute git clone for each repository.

But in this example the command jq -r '.[]' don't works.... This return the entire json on each repeat.


Viewing all articles
Browse latest Browse all 527

Trending Articles



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