JSON
require json then to_json and JSON.parse convert data.
Example
require "json"
data = { name: "Ada", tags: ["a", "b"] }
s = data.to_json
puts s
puts JSON.parse(s)["tags"].inspect
puts JSON.parse(s, symbolize_names: true)[:name]Result
{"name":"Ada","tags":["a","b"]}
["a", "b"]
AdaExercise
Parse text.
JSON.(s)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.