Assuming that the sample input above is inside a JSON array in file file.json, i.e.:
[
{"name": "Jenkins", "version": "Jenkins-2.22"},
{"name": "FitNesse", "version": "FitNesse-2.1"},
{"name": "Quint","version": "Quint-2.12"},
{"name": "Otto","version": "Otto-1.0"},
{"name": "Gradle","version": "Gradle-1.1"}
]
Note: The only change required to make the commands below work in Bash 3.x too is to replace readarray -t versions with IFS=$'\n' read -d '' -ra versions
Using Bash 4.x and jq:
jq must be installed first, but that's well worth the effort, if feasible: it enables sophisticated, robust JSON parsing.
# Extract the version numbers and read them into a Bash array.
readarray -t versions < <(jq -r '.[].version' file.json)
# Print the array.
printf '%s\n' "${versions[@]}"
The above yields:
Jenkins-2.22
FitNesse-2.1
Quint-2.12
Otto-1.0
Gradle-1.1
Using Bash 4.x and awk:
If you cannot install jq, the following awk solution is an alternative, but note that it is much less robust and relies on the JSON to be formatted exactly as above.
This warning applies to any solution using standard utilities (awk, grep, sed, ...) - only a dedicated JSON parser will work robustly.
readarray -t versions < <(awk -F\" 'NF>1 { print $(NF-1) }' file.json)
# Print the array.
printf '%s\n' "${versions[@]}"