Method: Oj::StreamWriter#push_key

Defined in:
ext/oj/stream_writer.c

#push_key(key) ⇒ Object

Pushes a key onto the JSON document. The key will be used for the next push if currently in a JSON object and ignored otherwise. If a key is provided on the next push then that new key will be ignored.

  • key [String] the key pending for the next push



136
137
138
139
140
141
142
143
144
145
# File 'ext/oj/stream_writer.c', line 136

static VALUE stream_writer_push_key(VALUE self, VALUE key) {
    StreamWriter sw;
    TypedData_Get_Struct(self, struct _streamWriter, &oj_stream_writer_type, sw);

    oj_str_writer_push_key(&sw->sw, StringValuePtr(key));
    if (sw->flush_limit < sw->sw.out.cur - sw->sw.out.buf) {
        stream_writer_write(sw);
    }
    return Qnil;
}