JSON can be a little hard to read because it's generally meant to be served without characters such as spaces and newlines that would make it human-readable.
Here's output from the fast ticker:
{
"result":"success",
"data":{
"last_local":{
"value":"136.87303",
"value_int":"13687303",
"display":"$136.87",
"display_short":"$136.87",
"currency":"USD"
},
"last":{
"value":"136.87303",
"value_int":"13687303",
"display":"$136.87",
"display_short":"$136.87",
"currency":"USD"
},
"last_orig":{
"value":"136.87303",
"value_int":"13687303",
"display":"$136.87",
"display_short":"$136.87",
"currency":"USD"
},
"last_all":{
"value":"136.87303",
"value_int":"13687303",
"display":"$136.87",
"display_short":"$136.87",
"currency":"USD"
},
"buy":{
"value":"136.10500",
"value_int":"13610500",
"display":"$136.11",
"display_short":"$136.11",
"currency":"USD"
},
"sell":{
"value":"136.87250",
"value_int":"13687250",
"display":"$136.87",
"display_short":"$136.87",
"currency":"USD"
},
"now":"1381085718504609"
}
}
The "result" item is always guaranteed to be there, but has of course varying content based on whether or not the call was successful. The "data" element contains a series of prices, with each name indicating its price.
Most JSON parsers in interpreted languages such as Ruby, PHP, and Python parse JSON into a hash or dictionary. You'd want the value of the "value" key of the "last" key of the "data" key.
Here's a one-liner version in Ruby for the v2 ticker:
ruby -e '%w(open-uri json).each{|b| require b}; open("http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast") {|d| puts JSON.parse(d.read)["data"]["last"]["value"]}'
Or something a little more readable:
require "open-uri"
require "json"
open("http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast") do |d|
json = JSON.parse(d.read)
puts json["data"]["last"]["value"]
end
Here's a one-liner version in Ruby for the old ticker:
ruby -e '%w(open-uri json).each{|b| require b}; open("https://mtgox.com/api/1/BTCUSD/ticker") {|d| puts JSON.parse(d.read)["return"]["last"]["value"]}'
Or something a little more readable:
require "open-uri"
require "json"
open("https://mtgox.com/api/1/BTCUSD/ticker") do |d|
json = JSON.parse(d.read)
puts json["return"]["last"]["value"]
end