Reading JSON data

require 'open-uri'
require 'json'

url = 'http://search.twitter.com/search.json?q=edinburgh+jobs&rpp=5&include_entities=true&result_type=mixed'

buffer = open(url, "UserAgent" => "Ruby-Wget").read

# convert JSON data into a hash
json = JSON.parse(buffer)


result = json['results'].map do |tweet|
  [tweet['from_user_name'], tweet['text']]
end

result.each {|x| puts ("%+6s: %s" % x)}


Tags:
Source:
1556hrs.txt
Published:
03-06-2012 15:56