Get JSON value from URL in BASH

bash, json, parsing, url

Solution

best thing to do is use a tool with a JSON parser. For example:

value=$(
  curl -s "$url" |
  ruby -rjson -e 'data = JSON.parse(STDIN.read); puts data["latest"]["snapshot"]'
)

Problem

I need to get the "snapshot" value at the top of the file from this url: https://s3.amazonaws.com/Minecraft.Download/versions/versions.json So I should get a variable that contains "14w08a" when I run the command to parse the json.

Original source

Related problems