sinatraでhashデータをJSONとして返す方法
方法
require 'json' return #{hash}.to_json
例
require 'sinatra' require 'json' get '/top' do hash = { "key1" => 1, "key2" => 2, "key3" => 3, } return hash.to_json end
require 'json' return #{hash}.to_json
require 'sinatra' require 'json' get '/top' do hash = { "key1" => 1, "key2" => 2, "key3" => 3, } return hash.to_json end