I have a JSON output that contains a list of objects stored in a variable. (I may not be phrasing that right)[  {    item1: value1,    item2: value2,    sub items: [      {        subitem: subvalue      }    ]  },  {    item1: value1_2,    item2: value2_2,    sub items_2: [      {        subitem_2: subvalue_2      }    ]  }]I need all the values for item2 in a array for a bash script to be run on ubuntu 14.04.1.I have found a bunch of ways to get the entire result into an array but not just the items I need
parse one field from an JSON array into bash array
bash;ubuntu;shell script;array;json
Using jq :$ cat json[  {    item1: value1,    item2: value2,    sub items: [      {        subitem: subvalue      }    ]  },  {    item1: value1_2,    item2: value2_2,    sub items_2: [      {        subitem_2: subvalue_2      }    ]  }]CODE:arr=( $(jq -r '.[].item2' json) )printf '%s\n' ${arr[@]}OUTPUT:value2value2_2