Method: Oj::Doc.open
- Defined in:
- ext/oj/fast.c
.open(json) ⇒ Object
Parses a JSON document String and then yields to the provided block if one is given with an instance of the Oj::Doc as the single yield parameter. If a block is not given then an Oj::Doc instance is returned and must be closed with a call to the #close() method when no longer needed.
@param [String] json JSON document string
method call
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 |
# File 'ext/oj/fast.c', line 1082 static VALUE doc_open(VALUE clas, VALUE str) { char *json; size_t len; volatile VALUE obj; int given = rb_block_given_p(); Check_Type(str, T_STRING); len = RSTRING_LEN(str) + 1; json = OJ_R_ALLOC_N(char, len); memcpy(json, StringValuePtr(str), len); obj = parse_json(clas, json, given); // TBD is this needed /* if (given) { OJ_R_FREE(json); } */ return obj; } |