oj 3.16.1 → 3.16.4

Sign up to get free protection for your applications and to get access to all the features.
data/ext/oj/oj.c CHANGED
@@ -33,10 +33,10 @@ ID oj_array_append_id;
33
33
  ID oj_array_end_id;
34
34
  ID oj_array_start_id;
35
35
  ID oj_as_json_id;
36
- ID oj_at_id;
37
36
  ID oj_begin_id;
38
37
  ID oj_bigdecimal_id;
39
38
  ID oj_end_id;
39
+ ID oj_eofq_id;
40
40
  ID oj_exclude_end_id;
41
41
  ID oj_error_id;
42
42
  ID oj_file_id;
@@ -51,6 +51,7 @@ ID oj_json_create_id;
51
51
  ID oj_length_id;
52
52
  ID oj_new_id;
53
53
  ID oj_parse_id;
54
+ ID oj_plus_id;
54
55
  ID oj_pos_id;
55
56
  ID oj_raw_json_id;
56
57
  ID oj_read_id;
@@ -91,9 +92,7 @@ VALUE oj_array_class_sym;
91
92
  VALUE oj_create_additions_sym;
92
93
  VALUE oj_decimal_class_sym;
93
94
  VALUE oj_hash_class_sym;
94
- VALUE oj_in_sym;
95
95
  VALUE oj_indent_sym;
96
- VALUE oj_nanosecond_sym;
97
96
  VALUE oj_object_class_sym;
98
97
  VALUE oj_quirks_mode_sym;
99
98
  VALUE oj_safe_sym;
@@ -240,72 +239,82 @@ struct _options oj_default_options = {
240
239
  * call-seq: default_options()
241
240
  *
242
241
  * Returns the default load and dump options as a Hash. The options are
243
- * - *:indent* [_Fixnum_|_String_|_nil_] number of spaces to indent each element in an JSON
244
- *document, zero or nil is no newline between JSON elements, negative indicates no newline between
245
- *top level JSON elements in a stream, a String indicates the string should be used for indentation
246
- * - *:circular* [_Boolean_|_nil_] support circular references while dumping as well as shared
247
- *references
242
+ * - *:indent* [_Fixnum_|_String_|_nil_] number of spaces to indent each element
243
+ * in an JSON document, zero or nil is no newline between JSON elements,
244
+ * negative indicates no newline between top level JSON elements in a stream,
245
+ * a String indicates the string should be used for indentation
246
+ * - *:circular* [_Boolean_|_nil_] support circular references while dumping as
247
+ * well as shared references
248
248
  * - *:auto_define* [_Boolean_|_nil_] automatically define classes if they do not exist
249
249
  * - *:symbol_keys* [_Boolean_|_nil_] use symbols instead of strings for hash keys
250
- * - *:escape_mode* [_:newline_|_:json_|_:slash_|_:xss_safe_|_:ascii_|_:unicode_xss_|_nil_] determines the
251
- *characters to escape
252
- * - *:class_cache* [_Boolean_|_nil_] cache classes for faster parsing (if dynamically modifying
253
- *classes or reloading classes then don't use this)
254
- * - *:mode* [_:object_|_:strict_|_:compat_|_:null_|_:custom_|_:rails_|_:wab_] load and dump modes
255
- *to use for JSON
250
+ * - *:escape_mode* [_:newline_|_:json_|_:slash_|_:xss_safe_|_:ascii_|_:unicode_xss_|_nil_]
251
+ * determines the characters to escape
252
+ * - *:class_cache* [_Boolean_|_nil_] cache classes for faster parsing (if dynamically
253
+ * modifying classes or reloading classes then don't use this)
254
+ * - *:mode* [_:object_|_:strict_|_:compat_|_:null_|_:custom_|_:rails_|_:wab_] load and
255
+ * dump modes to use for JSON
256
256
  * - *:time_format* [_:unix_|_:unix_zone_|_:xmlschema_|_:ruby_] time format when dumping
257
- * - *:bigdecimal_as_decimal* [_Boolean_|_nil_] dump BigDecimal as a decimal number or as a String
258
- * - *:bigdecimal_load* [_:bigdecimal_|_:float_|_:auto_|_:fast_|_:ruby_] load decimals as BigDecimal instead
259
- *of as a Float. :auto pick the most precise for the number of digits. :float should be the same as
260
- *ruby. :fast may require rounding but is must faster.
261
- * - *:compat_bigdecimal* [_true_|_false_] load decimals as BigDecimal instead of as a Float when in
262
- *compat or rails mode.
263
- * - *:create_id* [_String_|_nil_] create id for json compatible object encoding, default is
264
- *'json_class'
265
- * - *:create_additions* [_Boolean_|_nil_] if true allow creation of instances using create_id on
266
- *load.
267
- * - *:second_precision* [_Fixnum_|_nil_] number of digits after the decimal when dumping the
268
- *seconds portion of time
269
- * - *:float_precision* [_Fixnum_|_nil_] number of digits of precision when dumping floats, 0
270
- *indicates use Ruby
271
- * - *:float_format* [_String_] the C printf format string for printing floats. Default follows
272
- * the float_precision and will be changed if float_precision is changed. The string can be no more than 6 bytes.
257
+ * - *:bigdecimal_as_decimal* [_Boolean_|_nil_] dump BigDecimal as a decimal number or
258
+ * as a String
259
+ * - *:bigdecimal_load* [_:bigdecimal_|_:float_|_:auto_|_:fast_|_:ruby_] load decimals
260
+ * as BigDecimal instead of as a Float. :auto pick the most precise for the number
261
+ * of digits. :float should be the same as ruby. :fast may require rounding but is
262
+ * must faster.
263
+ * - *:compat_bigdecimal* [_true_|_false_] load decimals as BigDecimal instead of as
264
+ * a Float when in compat or rails mode.
265
+ * - *:create_id* [_String_|_nil_] create id for json compatible object encoding,
266
+ * default is 'json_class'
267
+ * - *:create_additions* [_Boolean_|_nil_] if true allow creation of instances using
268
+ * create_id on load.
269
+ * - *:second_precision* [_Fixnum_|_nil_] number of digits after the decimal when
270
+ * dumping the seconds portion of time
271
+ * - *:float_precision* [_Fixnum_|_nil_] number of digits of precision when dumping
272
+ * floats, 0 indicates use Ruby
273
+ * - *:float_format* [_String_] the C printf format string for printing floats.
274
+ * Default follows the float_precision and will be changed if float_precision is
275
+ * changed. The string can be no more than 6 bytes.
273
276
  * - *:use_to_json* [_Boolean_|_nil_] call to_json() methods on dump, default is false
274
277
  * - *:use_as_json* [_Boolean_|_nil_] call as_json() methods on dump, default is false
275
278
  * - *:use_raw_json* [_Boolean_|_nil_] call raw_json() methods on dump, default is false
276
- * - *:nilnil* [_Boolean_|_nil_] if true a nil input to load will return nil and not raise an
277
- *Exception
279
+ * - *:nilnil* [_Boolean_|_nil_] if true a nil input to load will return nil and
280
+ * not raise an Exception
278
281
  * - *:empty_string* [_Boolean_|_nil_] if true an empty input will not raise an Exception
279
282
  * - *:allow_gc* [_Boolean_|_nil_] allow or prohibit GC during parsing, default is true (allow)
280
- * - *:quirks_mode* [_true,_|_false_|_nil_] Allow single JSON values instead of documents, default
281
- *is true (allow)
282
- * - *:allow_invalid_unicode* [_true,_|_false_|_nil_] Allow invalid unicode, default is false (don't
283
- *allow)
284
- * - *:allow_nan* [_true,_|_false_|_nil_] Allow Nan, Infinity, and -Infinity to be parsed, default
285
- *is true (allow)
286
- * - *:indent_str* [_String_|_nil_] String to use for indentation, overriding the indent option is
287
- *not nil
288
- * - *:space* [_String_|_nil_] String to use for the space after the colon in JSON object fields
289
- * - *:space_before* [_String_|_nil_] String to use before the colon separator in JSON object fields
283
+ * - *:quirks_mode* [_true,_|_false_|_nil_] Allow single JSON values instead of
284
+ * documents, default is true (allow)
285
+ * - *:allow_invalid_unicode* [_true,_|_false_|_nil_] Allow invalid unicode,
286
+ * default is false (don't allow)
287
+ * - *:allow_nan* [_true,_|_false_|_nil_] Allow Nan, Infinity, and -Infinity to
288
+ * be parsed, default is true (allow)
289
+ * - *:indent_str* [_String_|_nil_] String to use for indentation, overriding the
290
+ * indent option is not nil
291
+ * - *:space* [_String_|_nil_] String to use for the space after the colon in JSON
292
+ * object fields
293
+ * - *:space_before* [_String_|_nil_] String to use before the colon separator in
294
+ * JSON object fields
290
295
  * - *:object_nl* [_String_|_nil_] String to use after a JSON object field value
291
296
  * - *:array_nl* [_String_|_nil_] String to use after a JSON array value
292
- * - *:nan* [_:null_|_:huge_|_:word_|_:raise_|_:auto_] how to dump Infinity and NaN. :null places a
293
- *null, :huge places a huge number, :word places Infinity or NaN, :raise raises and exception, :auto
294
- *uses default for each mode.
295
- * - *:hash_class* [_Class_|_nil_] Class to use instead of Hash on load, :object_class can also be
296
- *used
297
+ * - *:nan* [_:null_|_:huge_|_:word_|_:raise_|_:auto_] how to dump Infinity and
298
+ * NaN. :null places a null, :huge places a huge number, :word places Infinity
299
+ * or NaN, :raise raises and exception, :auto uses default for each mode.
300
+ * - *:hash_class* [_Class_|_nil_] Class to use instead of Hash on load,
301
+ * :object_class can also be used
297
302
  * - *:array_class* [_Class_|_nil_] Class to use instead of Array on load
298
- * - *:omit_nil* [_true_|_false_] if true Hash and Object attributes with nil values are omitted
299
- * - *:omit_null_byte* [_true_|_false_] if true null bytes in strings will be omitted when dumping
303
+ * - *:omit_nil* [_true_|_false_] if true Hash and Object attributes with nil
304
+ * values are omitted
305
+ * - *:omit_null_byte* [_true_|_false_] if true null bytes in strings will be
306
+ * omitted when dumping
300
307
  * - *:ignore* [_nil_|_Array_] either nil or an Array of classes to ignore when dumping
301
- * - *:ignore_under* [_Boolean_] if true then attributes that start with _ are ignored when dumping in
302
- *object or custom mode.
308
+ * - *:ignore_under* [_Boolean_] if true then attributes that start with _ are
309
+ * ignored when dumping in object or custom mode.
303
310
  * - *:cache_keys* [_Boolean_] if true then hash keys are cached if less than 35 bytes.
304
- * - *:cache_str* [_Fixnum_] maximum string value length to cache (strings less than this are cached)
311
+ * - *:cache_str* [_Fixnum_] maximum string value length to cache (strings less
312
+ * than this are cached)
305
313
  * - *:integer_range* [_Range_] Dump integers outside range as strings.
306
- * - *:trace* [_true,_|_false_] Trace all load and dump calls, default is false (trace is off)
307
- * - *:safe* [_true,_|_false_] Safe mimic breaks JSON mimic to be safer, default is false (safe is
308
- *off)
314
+ * - *:trace* [_true,_|_false_] Trace all load and dump calls, default is false
315
+ * (trace is off)
316
+ * - *:safe* [_true,_|_false_] Safe mimic breaks JSON mimic to be safer, default
317
+ * is false (safe is off)
309
318
  *
310
319
  * Return [_Hash_] all current option settings.
311
320
  */
@@ -490,70 +499,67 @@ static VALUE get_def_opts(VALUE self) {
490
499
  *
491
500
  * Sets the default options for load and dump.
492
501
  * - *opts* [_Hash_] options to change
493
- * - *:indent* [_Fixnum_|_String_|_nil_] number of spaces to indent each element in a JSON
494
- *document or the String to use for indentation.
502
+ * - *:indent* [_Fixnum_|_String_|_nil_] number of spaces to indent each element
503
+ * in a JSON document or the String to use for indentation.
495
504
  * - :circular [_Boolean_|_nil_] support circular references while dumping.
496
505
  * - *:auto_define* [_Boolean_|_nil_] automatically define classes if they do not exist.
497
506
  * - *:symbol_keys* [_Boolean_|_nil_] convert hash keys to symbols.
498
507
  * - *:class_cache* [_Boolean_|_nil_] cache classes for faster parsing.
499
- * - *:escape* [_:newline_|_:json_|_:xss_safe_|_:ascii_|_unicode_xss_|_nil_] mode encodes all
500
- *high-bit characters as escaped sequences if :ascii, :json is standand UTF-8 JSON encoding,
501
- *:newline is the same as :json but newlines are not escaped, :unicode_xss allows unicode but
502
- *escapes &, <, and >, and any \u20xx characters along with some others, and :xss_safe escapes &, <,
503
- *and >, and some others.
504
- * - *:bigdecimal_as_decimal* [_Boolean_|_nil_] dump BigDecimal as a decimal number or as a
505
- *String.
506
- * - *:bigdecimal_load* [_:bigdecimal_|_:float_|_:auto_|_nil_] load decimals as BigDecimal instead
507
- *of as a Float. :auto pick the most precise for the number of digits.
508
- * - *:compat_bigdecimal* [_true_|_false_] load decimals as BigDecimal instead of as a Float in
509
- *compat mode.
510
- * - *:mode* [_:object_|_:strict_|_:compat_|_:null_|_:custom_|_:rails_|_:wab_] load and dump mode
511
- *to use for JSON :strict raises an exception when a non-supported Object is encountered. :compat
512
- *attempts to extract variable values from an Object using to_json() or to_hash() then it walks the
513
- *Object's variables if neither is found. The :object mode ignores to_hash() and to_json() methods
514
- *and encodes variables using code internal to the Oj gem. The :null mode ignores non-supported
515
- *Objects and replaces them with a null. The :custom mode honors all dump options. The :rails more
516
- *mimics rails and Active behavior.
517
- * - *:time_format* [_:unix_|_:xmlschema_|_:ruby_] time format when dumping in :compat mode :unix
518
- *decimal number denoting the number of seconds since 1/1/1970, :unix_zone decimal number denoting
519
- *the number of seconds since 1/1/1970 plus the utc_offset in the exponent, :xmlschema date-time
520
- *format taken from XML Schema as a String, :ruby Time.to_s formatted String.
508
+ * - *:escape* [_:newline_|_:json_|_:xss_safe_|_:ascii_|_unicode_xss_|_nil_]
509
+ * mode encodes all high-bit characters as escaped sequences if :ascii, :json
510
+ * is standand UTF-8 JSON encoding, :newline is the same as :json but newlines
511
+ * are not escaped, :unicode_xss allows unicode but escapes &, <, and >, and
512
+ * any \u20xx characters along with some others, and :xss_safe escapes &, <,
513
+ * and >, and some others.
514
+ * - *:bigdecimal_as_decimal* [_Boolean_|_nil_] dump BigDecimal as a decimal
515
+ * number or as a String.
516
+ * - *:bigdecimal_load* [_:bigdecimal_|_:float_|_:auto_|_nil_] load decimals as
517
+ * BigDecimal instead of as a Float. :auto pick the most precise for the number of digits.
518
+ * - *:compat_bigdecimal* [_true_|_false_] load decimals as BigDecimal instead
519
+ * of as a Float in compat mode.
520
+ * - *:mode* [_:object_|_:strict_|_:compat_|_:null_|_:custom_|_:rails_|_:wab_] load
521
+ * and dump mode to use for JSON :strict raises an exception when a non-supported
522
+ * Object is encountered. :compat attempts to extract variable values from an
523
+ * Object using to_json() or to_hash() then it walks the Object's variables if
524
+ * neither is found. The :object mode ignores to_hash() and to_json() methods
525
+ * and encodes variables using code internal to the Oj gem. The :null mode
526
+ * ignores non-supported Objects and replaces them with a null. The :custom
527
+ * mode honors all dump options. The :rails more mimics rails and Active behavior.
528
+ * - *:time_format* [_:unix_|_:xmlschema_|_:ruby_] time format when dumping in :compat
529
+ * mode :unix decimal number denoting the number of seconds since 1/1/1970,
530
+ * :unix_zone decimal number denoting the number of seconds since 1/1/1970
531
+ * plus the utc_offset in the exponent, :xmlschema date-time format taken
532
+ * from XML Schema as a String, :ruby Time.to_s formatted String.
521
533
  * - *:create_id* [_String_|_nil_] create id for json compatible object encoding
522
- * - *:create_additions* [_Boolean_|_nil_] if true allow creation of instances using create_id on
523
- *load.
524
- * - *:second_precision* [_Fixnum_|_nil_] number of digits after the decimal when dumping the
525
- *seconds portion of time.
526
- * - *:float_format* [_String_] the C printf format string for printing floats. Default follows
527
- * the float_precision and will be changed if float_precision is changed. The string can be no more than 6 bytes.
528
- * - *:float_precision* [_Fixnum_|_nil_] number of digits of precision when dumping floats, 0
529
- *indicates use Ruby.
534
+ * - *:create_additions* [_Boolean_|_nil_] if true allow creation of instances using create_id on load.
535
+ * - *:second_precision* [_Fixnum_|_nil_] number of digits after the decimal
536
+ * when dumping the seconds portion of time.
537
+ * - *:float_format* [_String_] the C printf format string for printing floats.
538
+ * Default follows the float_precision and will be changed if float_precision
539
+ * is changed. The string can be no more than 6 bytes.
540
+ * - *:float_precision* [_Fixnum_|_nil_] number of digits of precision when dumping floats, 0 indicates use Ruby.
530
541
  * - *:use_to_json* [_Boolean_|_nil_] call to_json() methods on dump, default is false.
531
542
  * - *:use_as_json* [_Boolean_|_nil_] call as_json() methods on dump, default is false.
532
543
  * - *:use_to_hash* [_Boolean_|_nil_] call to_hash() methods on dump, default is false.
533
544
  * - *:use_raw_json* [_Boolean_|_nil_] call raw_json() methods on dump, default is false.
534
- * - *:nilnil* [_Boolean_|_nil_] if true a nil input to load will return nil and not raise an
535
- *Exception.
545
+ * - *:nilnil* [_Boolean_|_nil_] if true a nil input to load will return nil and not raise an Exception.
536
546
  * - *:allow_gc* [_Boolean_|_nil_] allow or prohibit GC during parsing, default is true (allow).
537
- * - *:quirks_mode* [_Boolean_|_nil_] allow single JSON values instead of documents, default is
538
- *true (allow).
539
- * - *:allow_invalid_unicode* [_Boolean_|_nil_] allow invalid unicode, default is false (don't
540
- *allow).
547
+ * - *:quirks_mode* [_Boolean_|_nil_] allow single JSON values instead of documents, default is true (allow).
548
+ * - *:allow_invalid_unicode* [_Boolean_|_nil_] allow invalid unicode, default is false (don't allow).
541
549
  * - *:allow_nan* [_Boolean_|_nil_] allow Nan, Infinity, and -Infinity, default is true (allow).
542
550
  * - *:space* [_String_|_nil_] String to use for the space after the colon in JSON object fields.
543
- * - *:space_before* [_String_|_nil_] String to use before the colon separator in JSON object
544
- *fields.
551
+ * - *:space_before* [_String_|_nil_] String to use before the colon separator in JSON object fields.
545
552
  * - *:object_nl* [_String_|_nil_] String to use after a JSON object field value.
546
553
  * - *:array_nl* [_String_|_nil_] String to use after a JSON array value
547
- * - *:nan* [_:null_|_:huge_|_:word_|_:raise_] how to dump Infinity and NaN in null, strict, and
548
- *compat mode. :null places a null, :huge places a huge number, :word places Infinity or NaN, :raise
549
- *raises and exception, :auto uses default for each mode.
550
- * - *:hash_class* [_Class_|_nil_] Class to use instead of Hash on load, :object_class can also be
551
- *used.
554
+ * - *:nan* [_:null_|_:huge_|_:word_|_:raise_] how to dump Infinity and NaN in null,
555
+ * strict, and compat mode. :null places a null, :huge places a huge number, :word
556
+ * places Infinity or NaN, :raise raises and exception, :auto uses default for each mode.
557
+ * - *:hash_class* [_Class_|_nil_] Class to use instead of Hash on load, :object_class can also be used.
552
558
  * - *:array_class* [_Class_|_nil_] Class to use instead of Array on load.
553
559
  * - *:omit_nil* [_true_|_false_] if true Hash and Object attributes with nil values are omitted.
554
560
  * - *:ignore* [_nil_|Array] either nil or an Array of classes to ignore when dumping
555
- * - *:ignore_under* [_Boolean_] if true then attributes that start with _ are ignored when
556
- *dumping in object or custom mode.
561
+ * - *:ignore_under* [_Boolean_] if true then attributes that start with _ are
562
+ * ignored when dumping in object or custom mode.
557
563
  * - *:cache_keys* [_Boolean_] if true then hash keys are cached
558
564
  * - *:cache_str* [_Fixnum_] maximum string value length to cache (strings less than this are cached)
559
565
  * - *:integer_range* [_Range_] Dump integers outside range as strings.
@@ -1329,18 +1335,16 @@ static VALUE dump(int argc, VALUE *argv, VALUE self) {
1329
1335
  * will be called. The mode is set to :compat.
1330
1336
  * - *obj* [_Object_] Object to serialize as an JSON document String
1331
1337
  * - *options* [_Hash_]
1332
- * - *:max_nesting* [_Fixnum_|_boolean_] It true nesting is limited to 100. If a Fixnum nesting
1333
- * is set to the provided value. The option to detect circular references is available but is not
1334
- * compatible with the json gem., default is false or unlimited.
1335
- * - *:allow_nan* [_boolean_] If true non JSON compliant words such as Nan and Infinity will be
1336
- * used as appropriate, default is true.
1337
- * - *:quirks_mode* [_boolean_] Allow single JSON values instead of documents, default is true
1338
- * (allow).
1339
- * - *:indent* [_String_|_nil_] String to use for indentation, overriding the indent option if not
1340
- * nil.
1338
+ * - *:max_nesting* [_Fixnum_|_boolean_] It true nesting is limited to 100.
1339
+ * If a Fixnum nesting is set to the provided value. The option to detect
1340
+ * circular references is available but is not compatible with the json gem.,
1341
+ * default is false or unlimited.
1342
+ * - *:allow_nan* [_boolean_] If true non JSON compliant words such as Nan and
1343
+ * Infinity will be used as appropriate, default is true.
1344
+ * - *:quirks_mode* [_boolean_] Allow single JSON values instead of documents, default is true (allow).
1345
+ * - *:indent* [_String_|_nil_] String to use for indentation, overriding the indent option if not nil.
1341
1346
  * - *:space* [_String_|_nil_] String to use for the space after the colon in JSON object fields.
1342
- * - *:space_before* [_String_|_nil_] String to use before the colon separator in JSON object
1343
- * fields.
1347
+ * - *:space_before* [_String_|_nil_] String to use before the colon separator in JSON object fields.
1344
1348
  * - *:object_nl* [_String_|_nil_] String to use after a JSON object field value.
1345
1349
  * - *:array_nl* [_String_|_nil_] String to use after a JSON array value.
1346
1350
  * - *:trace* [_Boolean_] If true trace is turned on.
@@ -1435,10 +1439,10 @@ static VALUE to_stream(int argc, VALUE *argv, VALUE self) {
1435
1439
  *
1436
1440
  * - *clas* [_Class__|_Module_] Class or Module to be made special
1437
1441
  * - *create_object* [_Object_] object to call the create method on
1438
- * - *create_method* [_Symbol_] method on the clas that will create a new instance of the clas when
1439
- * given all the member values in the order specified.
1440
- * - *members* [_Symbol__|_String_] methods used to get the member values from instances of the
1441
- * clas.
1442
+ * - *create_method* [_Symbol_] method on the clas that will create a new instance
1443
+ * of the clas when given all the member values in the order specified.
1444
+ * - *members* [_Symbol__|_String_] methods used to get the member values from
1445
+ * instances of the clas.
1442
1446
  */
1443
1447
  static VALUE register_odd(int argc, VALUE *argv, VALUE self) {
1444
1448
  if (3 > argc) {
@@ -1471,10 +1475,10 @@ static VALUE register_odd(int argc, VALUE *argv, VALUE self) {
1471
1475
  *
1472
1476
  * - *clas* [_Class_|_Module_] Class or Module to be made special
1473
1477
  * - *create_object* [_Object_] object to call the create method on
1474
- * - *create_method* [_Symbol_] method on the clas that will create a new instance of the clas when
1475
- *given all the member values in the order specified.
1476
- * - *dump_method* [_Symbol_|_String_] method to call on the object being serialized to generate the
1477
- *raw JSON.
1478
+ * - *create_method* [_Symbol_] method on the clas that will create a new instance
1479
+ * of the clas when given all the member values in the order specified.
1480
+ * - *dump_method* [_Symbol_|_String_] method to call on the object being
1481
+ * serialized to generate the raw JSON.
1478
1482
  */
1479
1483
  static VALUE register_odd_raw(int argc, VALUE *argv, VALUE self) {
1480
1484
  if (3 > argc) {
@@ -1700,8 +1704,8 @@ extern VALUE oj_define_mimic_json(int argc, VALUE *argv, VALUE self);
1700
1704
  * - *:space_before* [_String_] String placed before a : delimiter
1701
1705
  * - *:object_nl* [_String_] String placed after a JSON object
1702
1706
  * - *:array_nl* [_String_] String placed after a JSON array
1703
- * - *:ascii_only* [_Boolean_] if not nil or false then use only ascii characters in the output.
1704
- * Note JSON.generate does support this even if it is not documented.
1707
+ * - *:ascii_only* [_Boolean_] if not nil or false then use only ascii characters
1708
+ * in the output. Note JSON.generate does support this even if it is not documented.
1705
1709
  *
1706
1710
  * Returns [_String_]generated JSON.
1707
1711
  */
@@ -1758,8 +1762,8 @@ static VALUE mem_report(VALUE self) {
1758
1762
  * global and options to methods allow additional behavior modifications. The
1759
1763
  * modes are:
1760
1764
  *
1761
- * - *:strict* mode will only allow the 7 basic JSON types to be serialized. Any other Object
1762
- * will raise an Exception.
1765
+ * - *:strict* mode will only allow the 7 basic JSON types to be serialized.
1766
+ * Any other Object will raise an Exception.
1763
1767
  *
1764
1768
  * - *:null* mode is similar to the :strict mode except any Object that is not
1765
1769
  * one of the JSON base types is replaced by a JSON null.
@@ -1843,10 +1847,10 @@ void Init_oj(void) {
1843
1847
  oj_array_end_id = rb_intern("array_end");
1844
1848
  oj_array_start_id = rb_intern("array_start");
1845
1849
  oj_as_json_id = rb_intern("as_json");
1846
- oj_at_id = rb_intern("at");
1847
1850
  oj_begin_id = rb_intern("begin");
1848
1851
  oj_bigdecimal_id = rb_intern("BigDecimal");
1849
1852
  oj_end_id = rb_intern("end");
1853
+ oj_eofq_id = rb_intern("eof?");
1850
1854
  oj_error_id = rb_intern("error");
1851
1855
  oj_exclude_end_id = rb_intern("exclude_end?");
1852
1856
  oj_file_id = rb_intern("file?");
@@ -1861,6 +1865,7 @@ void Init_oj(void) {
1861
1865
  oj_length_id = rb_intern("length");
1862
1866
  oj_new_id = rb_intern("new");
1863
1867
  oj_parse_id = rb_intern("parse");
1868
+ oj_plus_id = rb_intern("+");
1864
1869
  oj_pos_id = rb_intern("pos");
1865
1870
  oj_raw_json_id = rb_intern("raw_json");
1866
1871
  oj_read_id = rb_intern("read");
@@ -1993,14 +1998,10 @@ void Init_oj(void) {
1993
1998
  rb_gc_register_address(&oj_decimal_class_sym);
1994
1999
  oj_hash_class_sym = ID2SYM(rb_intern("hash_class"));
1995
2000
  rb_gc_register_address(&oj_hash_class_sym);
1996
- oj_in_sym = ID2SYM(rb_intern("in"));
1997
- rb_gc_register_address(&oj_in_sym);
1998
2001
  oj_indent_sym = ID2SYM(rb_intern("indent"));
1999
2002
  rb_gc_register_address(&oj_indent_sym);
2000
2003
  oj_max_nesting_sym = ID2SYM(rb_intern("max_nesting"));
2001
2004
  rb_gc_register_address(&oj_max_nesting_sym);
2002
- oj_nanosecond_sym = ID2SYM(rb_intern("nanosecond"));
2003
- rb_gc_register_address(&oj_nanosecond_sym);
2004
2005
  oj_object_class_sym = ID2SYM(rb_intern("object_class"));
2005
2006
  rb_gc_register_address(&oj_object_class_sym);
2006
2007
  oj_object_nl_sym = ID2SYM(rb_intern("object_nl"));
data/ext/oj/oj.h CHANGED
@@ -262,6 +262,8 @@ extern void oj_dump_leaf_to_json(Leaf leaf, Options copts, Out out);
262
262
  extern void oj_write_leaf_to_file(Leaf leaf, const char *path, Options copts);
263
263
  extern char *oj_longlong_to_string(long long num, bool negative, char *buf);
264
264
 
265
+ extern StrWriter oj_str_writer_unwrap(VALUE writer);
266
+
265
267
  extern void oj_str_writer_push_key(StrWriter sw, const char *key);
266
268
  extern void oj_str_writer_push_object(StrWriter sw, const char *key);
267
269
  extern void oj_str_writer_push_array(StrWriter sw, const char *key);
@@ -311,9 +313,7 @@ extern VALUE oj_ascii_only_sym;
311
313
  extern VALUE oj_create_additions_sym;
312
314
  extern VALUE oj_decimal_class_sym;
313
315
  extern VALUE oj_hash_class_sym;
314
- extern VALUE oj_in_sym;
315
316
  extern VALUE oj_indent_sym;
316
- extern VALUE oj_nanosecond_sym;
317
317
  extern VALUE oj_max_nesting_sym;
318
318
  extern VALUE oj_object_class_sym;
319
319
  extern VALUE oj_object_nl_sym;
@@ -331,10 +331,10 @@ extern ID oj_array_append_id;
331
331
  extern ID oj_array_end_id;
332
332
  extern ID oj_array_start_id;
333
333
  extern ID oj_as_json_id;
334
- extern ID oj_at_id;
335
334
  extern ID oj_begin_id;
336
335
  extern ID oj_bigdecimal_id;
337
336
  extern ID oj_end_id;
337
+ extern ID oj_eofq_id;
338
338
  extern ID oj_error_id;
339
339
  extern ID oj_exclude_end_id;
340
340
  extern ID oj_file_id;
@@ -349,6 +349,7 @@ extern ID oj_json_create_id;
349
349
  extern ID oj_length_id;
350
350
  extern ID oj_new_id;
351
351
  extern ID oj_parse_id;
352
+ extern ID oj_plus_id;
352
353
  extern ID oj_pos_id;
353
354
  extern ID oj_read_id;
354
355
  extern ID oj_readpartial_id;