Method: Oj.to_stream

Defined in:
ext/oj/oj.c

.to_stream(io, obj, options = {}) ⇒ Object

Dumps an Object to the specified IO stream.

  • io [IO] IO stream to write the JSON document to

  • obj [Object] Object to serialize as an JSON document String

  • options [Hash] formatting options

    • :indent [Fixnum] format expected

    • :circular [Boolean] allow circular references, default: false



1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
# File 'ext/oj/oj.c', line 1421

static VALUE to_stream(int argc, VALUE *argv, VALUE self) {
    struct _options copts = oj_default_options;

    if (3 == argc) {
        oj_parse_options(argv[2], &copts);
    }
    oj_write_obj_to_stream(argv[1], *argv, &copts);

    return Qnil;
}