JSONの読み書き
https://docs.ruby-lang.org/ja/latest/class/JSON.html
のサンプルコードを実行。
▶Run
code:ruby
require "json"
string=<<JSON
{ "a":1, "b":2, "c":3 }
JSON
hash = { a: 1, b: 2, c: 3 }
JSON
string
.class # => Hash
JSON
string
# => {"a"=>1, "b"=>2, "c"=>3}
JSON
string, symbolize_names: true
# => {:a=>1, :b=>2, :c=>3}
JSON
hash
.class # => String
JSON
hash
# => "{\"a\":1,\"b\":2,\"c\":3}"