Read_with_parse.rb
This content was produced by an LLM and could include errors.
このスクリプトは最も一般的なJSON読み込みです。File.read で得たJSON文字列を JSON.parse で解析し、文字列キーを持つハッシュ {"key" => "value"} を返します。parse はプリミティブ(JSON基本型)専用で、任意オブジェクト復元を許す load より安全な基本手段です。
require 'json'
#=> true
JSON.parse(File.read('input/json/file.json'))
#=> {"key" => "value"}
Ruby 4.0.6