Ruby 3 · Errors and files

Work with JSON

Convert between Ruby hashes and JSON text.

require "json"

text = JSON.generate({ name: "Ada", tags: ["a", "b"] })
data = JSON.parse(text, symbolize_names: true)

Official Ruby 3 documentation

More errors and files commands

All errors and files commands · Ruby 3 cheatsheet

Was this page helpful?