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