Currently I am doing the Ruby on Rails Tutorial from Michael H… I am
developing that code within the cloud9 IDE. What I am interested in
ultimately is to develop some application relating to cryptocurrencies
especially the counterparty protocol. For that, I want to read data from
the blockscan API (google that). There are API requests I want to made
for receiving blockchain data. This data is delivered in json.
Now as a starter, I do not know how to read this json data into a Ruby
variable, do something with it, and render it to a page. Can some one
provide me example code (only the essential lines) that would accomplish
what I wish to do?
Currently I am doing the Ruby on Rails Tutorial from Michael H… I am
developing that code within the cloud9 IDE. What I am interested in
ultimately is to develop some application relating to cryptocurrencies
especially the counterparty protocol. For that, I want to read data from
the blockscan API (google that). There are API requests I want to made
for receiving blockchain data. This data is delivered in json.
Now as a starter, I do not know how to read this json data into a Ruby
variable, do something with it, and render it to a page. Can some one
provide me example code (only the essential lines) that would accomplish
what I wish to do?
Sincerely
After you receive the json data from api server, you can use the JSON
module to parse these data. For example:
require 'open-uri'
require 'json'
req =
open('http://xcp.blockscan.com/api2?module=asset&action=list&page=1&count=10')
data = JSON.load(req.read)
The var data that return by JSON.load function may be a Ruby Hash or
Array type.
If you want to render it to a page, you can use it in the view and
display it.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.