Method: Oj::Doc#size

Defined in:
ext/oj/fast.c

#sizeObject

Returns the number of nodes in the JSON document where a node is any one of the basic JSON components.

Examples:

Oj::Doc.open('[1,2,3]') { |doc| doc.size() }  #=> 4

Returns:

  • Returns the size of the JSON document.



1607
1608
1609
1610
1611
# File 'ext/oj/fast.c', line 1607

static VALUE doc_size(VALUE self) {
    Doc d;
    TypedData_Get_Struct(self, struct _doc, &oj_doc_type, d);
    return ULONG2NUM(d->size);
}