Method: Oj.generate

Defined in:
ext/oj/oj.c

.generate(obj, opts = nil) ⇒ Object

Encode obj as a JSON String. The obj argument must be a Hash, Array, or respond to to_h or to_json. Options other than those listed such as :allow_nan or :max_nesting are ignored. Calling this method will call Oj.mimic_JSON if it is not already called.

  • obj [Object_|Hash|Array] object to convert to a JSON String

  • opts [Hash] options

    • :indent [String] String to use for indentation.

    • :space [String] String placed after a , or : delimiter

    • :space_before [String] String placed before a : delimiter

    • :object_nl [String] String placed after a JSON object

    • :array_nl [String] String placed after a JSON array

    • :ascii_only [Boolean] if not nil or false then use only ascii characters in the output. Note JSON.generate does support this even if it is not documented.

Returns [String]generated JSON.



1713
# File 'ext/oj/oj.c', line 1713

extern VALUE oj_mimic_generate(int argc, VALUE *argv, VALUE self);