JSON形式の文字列をハッシュに変換する
code:ruby
require 'json'
s = <<-EOS
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
EOS
p JSON.parse(s)
code:出力