Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Kernel#JSON

(::string source, ?::JSON::options opts) -> untyped
(::_ToJson obj, ?::JSON::options opts) -> ::String
JSON(object, opts = nil)

If object is string-like, parse the string and return the parsed result as a Ruby data structure. Otherwise, generate a JSON text from the Ruby data structure object and return it.

The opts argument is passed through to generate/parse respectively. See generate and parse for their documentation.

See also #iterator? #lambda #Integer #load also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0