skip to main | skip to sidebar

temp blog

Monday, July 20, 2009

SinatraでJSON

Server side: 
require "rubygems"
require "sinatra"
require "json"

get '/action/' do
  content_type :json
  {:name => 'kyo', :age => 25}.to_json
end
 
Client side:
$.getJSON('/action/', function(json){
var name = json.name
var age = json.age
...
});

Posted by keyes at 10:01 AM

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2010 (86)
    • ►  September (25)
    • ►  August (9)
    • ►  July (4)
    • ►  June (4)
    • ►  May (13)
    • ►  April (7)
    • ►  March (14)
    • ►  February (3)
    • ►  January (7)
  • ▼  2009 (304)
    • ►  December (25)
    • ►  November (22)
    • ►  October (40)
    • ►  September (9)
    • ►  August (18)
    • ▼  July (16)
      • Tile のミラーをGitで作る
      • Ruby1.9
      • SinatraでJSON
      • Mongrel Long URL
      • bookmarklet lino anywhere
      • bookmarklet post fusen
      • TiLeが起動しない!
      • Yahoo Auctionの画像アップ
      • New Apple Keyboard
      • 漢字コードの範囲
      • tmux
      • stopPropagation
      • Hana
      • Mighty Mouse 電池交換
      • Hana
      • Hana
    • ►  June (15)
    • ►  May (41)
    • ►  April (38)
    • ►  March (37)
    • ►  February (31)
    • ►  January (12)
  • ►  2008 (201)
    • ►  December (15)
    • ►  November (15)
    • ►  October (25)
    • ►  September (32)
    • ►  August (21)
    • ►  July (20)
    • ►  June (44)
    • ►  May (29)
  • ►  2006 (21)
    • ►  October (2)
    • ►  July (8)
    • ►  June (1)
    • ►  April (8)
    • ►  March (2)

Links

  • Google News

About Me

keyes
View my complete profile