Haskell で json を扱う
JSON Schema が提案されたりして、ますます使う機会が増えてきた JSON。
Haskell では http://hackage.haskell.org/cgi-bin/hackage-scripts/package/json を使って JSON を扱うことができる。
そこで、http://delicious.com の hot list をとってくるサンプルを書いた。
このサンプルは
- http://hackage.haskell.org/cgi-bin/hackage-scripts/package/json
- http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HTTP
- http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string
を使っているため、これらをあらかじめ cabal でインストールしておく必要があります。
実行結果
% ghc --make delicious.hs % ./delicious url: http://na.blackberry.com/eng/services/appworld/ title: BlackBerry - The Official BlackBerry App World – BlackBerry App Store tags: ["blackberry","mobile","apps","appstore","app","software","download","store","applications","world"] dt: 2009-04-19T09:02:56Z url: http://adage.com/article?article_id=135735 title: Tropicana Line's Sales Plunge 20% Post-Rebranding - Advertising Age - News tags: ["design","branding","marketing","tropicana","advertising","business","packaging","rebranding","logo","sales"] dt: 2009-04-19T09:02:56Z url: http://ejohn.org/blog/javascript-testing-does-not-scale/ title: John Resig - JavaScript Testing Does Not Scale tags: ["javascript","testing","jquery","scalability","distributed","browser","browsers","development","crossbrowser","test"] dt: 2009-04-19T09:02:56Z url: http://www.google.com/webmasters/provider/ title: Google Services for Websites tags: ["google","tools","webmaster","seo","web","webdesign","webdev","services","hosting","search"] dt: 2009-04-19T09:02:56Z url: http://www.webdesignerwall.com/general/finding-inspiration/ title: Finding Inspiration tags: ["inspiration","design","webdesign","tips","creative","graphics","web","freelance","art","freelancing"] dt: 2009-04-19T09:02:56Z
追記
gist という便利なサービスがあることを知ったので、そっちに貼りつけてみる。
番号がちょうど 98000 で、なんとなく嬉しい。