user2751: I want to do a simple app that refreshes every minute to tell me the current exchange rate by Mtgox but I have a problem interpreting the JSON that some APIs return:

Mtgox's fast ticker returns this JSON. The question is, what's the value that I have to retrieve? There are a lot and I don't understand them, and I don't find proper docs.
Bitcoincharts' API has the Markets Data endpoint, and it returns the market I want under the symbol "mtgoxUSD", however it tells me the date time of latest trade, the last buy/ask, but doesn't tell me the exchange rate of the latest trade.

Am I missing something?

user1409: 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


2751: <p>I want to do a simple app that refreshes every minute to tell me the current exchange rate by Mtgox but I have a problem interpreting the JSON that some APIs return:</p>

<ul>
<li><p>Mtgox's fast ticker returns <a href="http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast" rel="nofollow">this JSON</a>. The question is, what's the value that I have to retrieve? There are a lot and I don't understand them, and I don't find proper docs.</p></li>
<li><p>Bitcoincharts' API has the <a href="http://bitcoincharts.com/about/markets-api/" rel="nofollow">Markets Data endpoint</a>, and it returns the market I want under the symbol "mtgoxUSD", however it tells me the date time of latest trade, the last buy/ask, but doesn't tell me <strong>the exchange rate of the latest trade</strong>.</p></li>
</ul>

<p>Am I missing something?</p>
 1409: <p>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.</p>

<p>Here's output from the fast ticker:</p>

<pre><code>{
  "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"
  }
}
</code></pre>

<p>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.</p>

<p>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.</p>

<p>Here's a one-liner version in Ruby for the v2 ticker:</p>

<pre><code>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"]}'
</code></pre>

<p>Or something a little more readable:</p>

<pre><code>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
</code></pre>

<p>Here's a one-liner version in Ruby for the old ticker:</p>

<pre><code>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"]}'
</code></pre>

<p>Or something a little more readable:</p>

<pre><code>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
</code></pre>
