Monday, April 24, 2017

Reading a Json String on Linux/Unix Shell? Here's how I use jq

This prints out all the fields in your json string:
jq keys YourJsonString
This prints out the the field called "accession" of all your nodes:
jq '.files[].accession' YourJsonString
Usually, assuming the outputs follow a constant order, you can juxtapose the fields you need together to make a table by typing this:
paste -s <(jq '.files[].href' test) <(jq '.files[].accession' YourJsonString)

No comments:

Post a Comment