Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Kernel#JSON
JSON(object, *args)
ext/json/lib/json/common.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/ext/json/lib/json/common.rb, line 679
def JSON(object, *args)
if object.respond_to? :to_str
JSON.parse(object.to_str, args.first)
else
JSON.generate(object, args.first)
end
end
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.