Skip to content

Instantly share code, notes, and snippets.

@btoone
Created March 30, 2012 22:02
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 btoone/2255909 to your computer and use it in GitHub Desktop.
Save btoone/2255909 to your computer and use it in GitHub Desktop.
Parse JSON
require 'json'
json = '{
"description":"the description for this gist",
"public":true,
"files":{
"file1.txt":{
"content":"String file contents"
}
}
}'
hash = {
"description" => "the description for this gist",
"public" => true,
"files" => {
"file1.txt" => {
"content" => "String file contents"
}
}
}
h = JSON.parse(json)
p h.class
p h
p h['description']
puts ""
j = JSON.generate(hash)
p j.class
p j
puts j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment