Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
JSON#fast_generate
JSON.fast_generate(obj, opts) → new_string
ext/json/lib/json/common.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/ext/json/lib/json/common.rb, line 328
def fast_generate(obj, opts = nil)
if State === opts
state = opts
else
state = JSON.create_fast_state.configure(opts)
end
state.generate(obj)
end
Arguments obj and opts here are the same as arguments obj and opts in JSON.generate.
By default, generates JSON data without checking for circular references in obj (option max_nesting set to false, disabled).
Raises an exception if obj contains circular references:
Example
a = []; b = []; a.push(b); b.push(a) # Raises SystemStackError (stack level too deep): JSON.fast_generate(a)