Skip to content

Instantly share code, notes, and snippets.

@mperham
Created June 12, 2009 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mperham/128903 to your computer and use it in GitHub Desktop.
Save mperham/128903 to your computer and use it in GitHub Desktop.
# I assume this is valid UTF-8 encoded JSON
valid_json = '{
"status": "ok",
"articles": [
{
"url": "http://www.idiomag.com/peek/85310/pearl_jam",
"confidence": 0.018548,
"published_datetime": "2009-06-02T12:04:19Z",
"zemified": 0,
"title": " Pearl Jam Debut \u00e2\u0080\u009cBackspacer\u00e2\u0080\u009d Track, Cover Art on Conan O\u00e2\u0080\u0099Brien\u00e2\u0080\u0099s \u00e2\u0080\u009cTonight Show\u00e2\u0080\u009d "
}
]
}'
require 'json'
hash = JSON.parse(valid_json)
puts hash['articles'][0]['title'] # print out the mucked-up title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment