0

here i am parsing a json file and storing values as array.

arr1=(`jq '.animal.names'  123.json | sed...`)

output: fox tiger lion

now i need to parse values dynamically (i = birds or fish)

eg    arr1=(`jq .$i.names  123.json | sed...`)
it should be as 

arr1=(`jq '.bird.names'  123.json | sed...`) 
or      
arr1=(`jq '.fish.names'  123.json | sed...`).

Some guidance will be helpful.

Cyrus
  • 77,979
  • 13
  • 71
  • 125
mebb
  • 59
  • 6
  • So, your question is not about jq output and bash arrays, but how to pass a bash variable to a jq command, which is well documented around SO, like here: https://stackoverflow.com/questions/40027395/passing-bash-variable-to-jq – thanasisp Oct 04 '20 at 19:24
  • 1
    If you mean something more than just passing a variable, please update your question with a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) with exact commands, some small input and the expected output. – thanasisp Oct 04 '20 at 20:11
  • 2
    Does this answer your question? [Passing bash variable to jq](https://stackoverflow.com/questions/40027395/passing-bash-variable-to-jq) – Hedi Bejaoui Oct 04 '20 at 20:47

0 Answers0