oj 3.0.5 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/oj/compat.c +3 -3
- data/ext/oj/custom.c +20 -24
- data/ext/oj/dump.c +1 -1
- data/ext/oj/dump_compat.c +11 -20
- data/ext/oj/dump_object.c +3 -3
- data/ext/oj/dump_strict.c +1 -1
- data/ext/oj/mimic_json.c +2 -1
- data/ext/oj/object.c +1 -1
- data/ext/oj/oj.c +6 -3
- data/ext/oj/parse.c +1 -1
- data/ext/oj/rails.c +30 -7
- data/ext/oj/rails.h +3 -0
- data/ext/oj/rxclass.c +1 -1
- data/lib/oj/version.rb +1 -1
- data/test/test_compat.rb +15 -1
- metadata +65 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d2a2d3b4fd246384540dcb2b35b335bddd57388
|
4
|
+
data.tar.gz: 89b10cb944cf00447fcc96cadcc4098c6fbd88df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 826667035ad04a8e76a63e9d1ada8ead7c3d2f7d3f83876a28d6cec476cdf8cb4bfd57f61d3607ea2bb9edd489b6d619b27b0299d89466cafd71f25e5a744240
|
7
|
+
data.tar.gz: 8a6d58b91255b62fe651a5dee8eb8f302ec20a60cf900061ec8dfdcd7bda5fcf331e68eca9416efbf8068fdc0b05d77c17e3360c70d7a376d32cebbc8e4030bb
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [](http://www.ohler.com/oj) gem
|
2
2
|
|
3
3
|
[](http://travis-ci.org/ohler55/oj?branch=master)  
|
4
4
|
|
data/ext/oj/compat.c
CHANGED
@@ -40,7 +40,7 @@ hash_set_cstr(ParseInfo pi, Val kval, const char *str, size_t len, const char *o
|
|
40
40
|
}
|
41
41
|
}
|
42
42
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
43
|
-
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, len);
|
43
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
44
44
|
|
45
45
|
if (Qnil != clas) {
|
46
46
|
rstr = rb_funcall(clas, oj_json_create_id, 1, rstr);
|
@@ -112,7 +112,7 @@ add_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) {
|
|
112
112
|
|
113
113
|
rstr = oj_encode(rstr);
|
114
114
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
115
|
-
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, len);
|
115
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
116
116
|
|
117
117
|
if (Qnil != clas) {
|
118
118
|
pi->stack.head->val = rb_funcall(clas, oj_json_create_id, 1, rstr);
|
@@ -181,7 +181,7 @@ array_append_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) {
|
|
181
181
|
|
182
182
|
rstr = oj_encode(rstr);
|
183
183
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
184
|
-
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, len);
|
184
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
185
185
|
|
186
186
|
if (Qnil != clas) {
|
187
187
|
rb_ary_push(stack_peek(&pi->stack)->val, rb_funcall(clas, oj_json_create_id, 1, rstr));
|
data/ext/oj/custom.c
CHANGED
@@ -34,7 +34,7 @@ static void
|
|
34
34
|
bigdecimal_dump(VALUE obj, int depth, Out out) {
|
35
35
|
volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
|
36
36
|
const char *str = rb_string_value_ptr((VALUE*)&rstr);
|
37
|
-
int len = RSTRING_LEN(rstr);
|
37
|
+
int len = (int)RSTRING_LEN(rstr);
|
38
38
|
|
39
39
|
if (0 == strcasecmp("Infinity", str)) {
|
40
40
|
str = oj_nan_str(obj, out->opts->dump_opts.nan_dump, out->opts->mode, true, &len);
|
@@ -373,7 +373,7 @@ dump_odd(VALUE obj, Odd odd, VALUE clas, int depth, Out out) {
|
|
373
373
|
rb_raise(rb_eEncodingError, "Invalid type for raw JSON.\n");
|
374
374
|
} else {
|
375
375
|
const char *s = rb_string_value_ptr((VALUE*)&v);
|
376
|
-
int len = RSTRING_LEN(v);
|
376
|
+
int len = (int)RSTRING_LEN(v);
|
377
377
|
const char *name = rb_id2name(*odd->attrs);
|
378
378
|
size_t nlen = strlen(name);
|
379
379
|
|
@@ -448,7 +448,15 @@ dump_common(VALUE obj, int depth, Out out) {
|
|
448
448
|
const char *s;
|
449
449
|
int len;
|
450
450
|
|
451
|
-
|
451
|
+
#if HAS_METHOD_ARITY
|
452
|
+
if (0 == rb_obj_method_arity(obj, oj_to_json_id)) {
|
453
|
+
rs = rb_funcall(obj, oj_to_json_id, 0);
|
454
|
+
} else {
|
455
|
+
rs = rb_funcall2(obj, oj_to_json_id, out->argc, out->argv);
|
456
|
+
}
|
457
|
+
#else
|
458
|
+
rs = rb_funcall2(obj, oj_to_json_id, out->argc, out->argv);
|
459
|
+
#endif
|
452
460
|
s = rb_string_value_ptr((VALUE*)&rs);
|
453
461
|
len = (int)RSTRING_LEN(rs);
|
454
462
|
|
@@ -458,30 +466,18 @@ dump_common(VALUE obj, int depth, Out out) {
|
|
458
466
|
*out->cur = '\0';
|
459
467
|
} else if (Yes == out->opts->as_json && rb_respond_to(obj, oj_as_json_id)) {
|
460
468
|
volatile VALUE aj;
|
461
|
-
int arity;
|
462
469
|
|
463
|
-
#if HAS_METHOD_ARITY
|
464
|
-
arity = rb_obj_method_arity(obj, oj_as_json_id);
|
465
|
-
#else
|
466
|
-
arity = out->argc;
|
467
|
-
#endif
|
468
470
|
// Some classes elect to not take an options argument so check the arity
|
469
471
|
// of as_json.
|
470
|
-
|
471
|
-
|
472
|
+
#if HAS_METHOD_ARITY
|
473
|
+
if (0 == rb_obj_method_arity(obj, oj_as_json_id)) {
|
472
474
|
aj = rb_funcall(obj, oj_as_json_id, 0);
|
473
|
-
|
474
|
-
case 1:
|
475
|
-
if (1 <= out->argc) {
|
476
|
-
aj = rb_funcall2(obj, oj_as_json_id, 1, (VALUE*)out->argv);
|
477
|
-
} else {
|
478
|
-
aj = rb_funcall(obj, oj_as_json_id, 1, Qnil);
|
479
|
-
}
|
480
|
-
break;
|
481
|
-
default:
|
475
|
+
} else {
|
482
476
|
aj = rb_funcall2(obj, oj_as_json_id, out->argc, out->argv);
|
483
|
-
break;
|
484
477
|
}
|
478
|
+
#else
|
479
|
+
aj = rb_funcall2(obj, oj_as_json_id, out->argc, out->argv);
|
480
|
+
#endif
|
485
481
|
// Catch the obvious brain damaged recursive dumping.
|
486
482
|
if (aj == obj) {
|
487
483
|
volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
|
@@ -904,7 +900,7 @@ hash_set_cstr(ParseInfo pi, Val kval, const char *str, size_t len, const char *o
|
|
904
900
|
}
|
905
901
|
}
|
906
902
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
907
|
-
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, len);
|
903
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
908
904
|
|
909
905
|
if (Qnil != clas) {
|
910
906
|
rstr = rb_funcall(clas, oj_json_create_id, 1, rstr);
|
@@ -916,7 +912,7 @@ hash_set_cstr(ParseInfo pi, Val kval, const char *str, size_t len, const char *o
|
|
916
912
|
break;
|
917
913
|
case T_HASH:
|
918
914
|
if (4 == parent->klen && NULL != parent->key && rb_cTime == parent->clas && 0 == strncmp("time", parent->key, 4)) {
|
919
|
-
if (Qnil == (parent->val = oj_parse_xml_time(str, len))) {
|
915
|
+
if (Qnil == (parent->val = oj_parse_xml_time(str, (int)len))) {
|
920
916
|
parent->val = rb_funcall(rb_cTime, rb_intern("parse"), 1, rb_str_new(str, len));
|
921
917
|
}
|
922
918
|
} else {
|
@@ -1038,7 +1034,7 @@ array_append_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) {
|
|
1038
1034
|
|
1039
1035
|
rstr = oj_encode(rstr);
|
1040
1036
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
1041
|
-
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, len);
|
1037
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
1042
1038
|
|
1043
1039
|
if (Qnil != clas) {
|
1044
1040
|
rb_ary_push(stack_peek(&pi->stack)->val, rb_funcall(clas, oj_json_create_id, 1, rstr));
|
data/ext/oj/dump.c
CHANGED
@@ -1037,7 +1037,7 @@ oj_dump_float(VALUE obj, int depth, Out out, bool as_ok) {
|
|
1037
1037
|
} else if (0 == out->opts->float_prec) {
|
1038
1038
|
volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
|
1039
1039
|
|
1040
|
-
cnt = RSTRING_LEN(rstr);
|
1040
|
+
cnt = (int)RSTRING_LEN(rstr);
|
1041
1041
|
if ((int)sizeof(buf) <= cnt) {
|
1042
1042
|
cnt = sizeof(buf) - 1;
|
1043
1043
|
}
|
data/ext/oj/dump_compat.c
CHANGED
@@ -118,7 +118,16 @@ dump_to_json(VALUE obj, Out out) {
|
|
118
118
|
const char *s;
|
119
119
|
int len;
|
120
120
|
|
121
|
+
#if HAS_METHOD_ARITY
|
122
|
+
if (0 == rb_obj_method_arity(obj, oj_to_json_id)) {
|
123
|
+
rs = rb_funcall(obj, oj_to_json_id, 0);
|
124
|
+
} else {
|
125
|
+
rs = rb_funcall2(obj, oj_to_json_id, out->argc, out->argv);
|
126
|
+
}
|
127
|
+
#else
|
121
128
|
rs = rb_funcall2(obj, oj_to_json_id, out->argc, out->argv);
|
129
|
+
#endif
|
130
|
+
|
122
131
|
s = rb_string_value_ptr((VALUE*)&rs);
|
123
132
|
len = (int)RSTRING_LEN(rs);
|
124
133
|
|
@@ -731,18 +740,8 @@ dump_obj(VALUE obj, int depth, Out out, bool as_ok) {
|
|
731
740
|
return;
|
732
741
|
}
|
733
742
|
if (as_ok && rb_respond_to(obj, oj_to_json_id)) {
|
734
|
-
|
735
|
-
const char *s;
|
736
|
-
int len;
|
737
|
-
|
738
|
-
rs = rb_funcall(obj, oj_to_json_id, 0);
|
739
|
-
s = rb_string_value_ptr((VALUE*)&rs);
|
740
|
-
len = (int)RSTRING_LEN(rs);
|
743
|
+
dump_to_json(obj, out);
|
741
744
|
|
742
|
-
assure_size(out, len + 1);
|
743
|
-
memcpy(out->cur, s, len);
|
744
|
-
out->cur += len;
|
745
|
-
*out->cur = '\0';
|
746
745
|
return;
|
747
746
|
}
|
748
747
|
// Nothing else matched so encode as a JSON object with Ruby obj members
|
@@ -772,15 +771,7 @@ dump_struct(VALUE obj, int depth, Out out, bool as_ok) {
|
|
772
771
|
return;
|
773
772
|
}
|
774
773
|
if (as_ok && rb_respond_to(obj, oj_to_json_id)) {
|
775
|
-
|
776
|
-
const char *s;
|
777
|
-
int len;
|
778
|
-
|
779
|
-
s = rb_string_value_ptr((VALUE*)&rs);
|
780
|
-
len = (int)RSTRING_LEN(rs);
|
781
|
-
assure_size(out, len);
|
782
|
-
memcpy(out->cur, s, len);
|
783
|
-
out->cur += len;
|
774
|
+
dump_to_json(obj, out);
|
784
775
|
|
785
776
|
return;
|
786
777
|
}
|
data/ext/oj/dump_object.c
CHANGED
@@ -40,7 +40,7 @@ dump_data(VALUE obj, int depth, Out out, bool as_ok) {
|
|
40
40
|
if (oj_bigdecimal_class == clas) {
|
41
41
|
volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
|
42
42
|
const char *str = rb_string_value_ptr((VALUE*)&rstr);
|
43
|
-
int len = RSTRING_LEN(rstr);
|
43
|
+
int len = (int)RSTRING_LEN(rstr);
|
44
44
|
|
45
45
|
if (Yes == out->opts->bigdec_as_num) {
|
46
46
|
oj_dump_raw(str, len, out);
|
@@ -70,7 +70,7 @@ dump_obj(VALUE obj, int depth, Out out, bool as_ok) {
|
|
70
70
|
if (oj_bigdecimal_class == clas) {
|
71
71
|
volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
|
72
72
|
const char *str = rb_string_value_ptr((VALUE*)&rstr);
|
73
|
-
int len = RSTRING_LEN(rstr);
|
73
|
+
int len = (int)RSTRING_LEN(rstr);
|
74
74
|
|
75
75
|
if (0 == strcasecmp("Infinity", str)) {
|
76
76
|
str = oj_nan_str(obj, out->opts->dump_opts.nan_dump, out->opts->mode, true, &len);
|
@@ -416,7 +416,7 @@ dump_odd(VALUE obj, Odd odd, VALUE clas, int depth, Out out) {
|
|
416
416
|
rb_raise(rb_eEncodingError, "Invalid type for raw JSON.\n");
|
417
417
|
} else {
|
418
418
|
const char *s = rb_string_value_ptr((VALUE*)&v);
|
419
|
-
int len = RSTRING_LEN(v);
|
419
|
+
int len = (int)RSTRING_LEN(v);
|
420
420
|
const char *name = rb_id2name(*odd->attrs);
|
421
421
|
size_t nlen = strlen(name);
|
422
422
|
|
data/ext/oj/dump_strict.c
CHANGED
@@ -108,7 +108,7 @@ dump_float(VALUE obj, int depth, Out out, bool as_ok) {
|
|
108
108
|
} else if (0 == out->opts->float_prec) {
|
109
109
|
volatile VALUE rstr = rb_funcall(obj, oj_to_s_id, 0);
|
110
110
|
|
111
|
-
cnt = RSTRING_LEN(rstr);
|
111
|
+
cnt = (int)RSTRING_LEN(rstr);
|
112
112
|
if ((int)sizeof(buf) <= cnt) {
|
113
113
|
cnt = sizeof(buf) - 1;
|
114
114
|
}
|
data/ext/oj/mimic_json.c
CHANGED
@@ -363,7 +363,8 @@ mimic_generate_core(int argc, VALUE *argv, Options copts) {
|
|
363
363
|
if (No == copts->nilnil && Qnil == *argv) {
|
364
364
|
rb_raise(rb_eTypeError, "nil not allowed.");
|
365
365
|
}
|
366
|
-
|
366
|
+
oj_dump_obj_to_json_using_params(*argv, copts, &out, argc - 1, argv + 1);
|
367
|
+
|
367
368
|
if (0 == out.buf) {
|
368
369
|
rb_raise(rb_eNoMemError, "Not enough memory.");
|
369
370
|
}
|
data/ext/oj/object.c
CHANGED
data/ext/oj/oj.c
CHANGED
@@ -960,7 +960,7 @@ dump(int argc, VALUE *argv, VALUE self) {
|
|
960
960
|
out.allocated = 0;
|
961
961
|
out.omit_nil = copts.dump_opts.omit_nil;
|
962
962
|
out.caller = CALLER_DUMP;
|
963
|
-
|
963
|
+
oj_dump_obj_to_json_using_params(*argv, &copts, &out, argc - 1,argv + 1);
|
964
964
|
if (0 == out.buf) {
|
965
965
|
rb_raise(rb_eNoMemError, "Not enough memory.");
|
966
966
|
}
|
@@ -982,7 +982,7 @@ dump(int argc, VALUE *argv, VALUE self) {
|
|
982
982
|
* - *:max_nesting* [_boolean_] It true nesting is limited to 100. The option to detect circular references is available but is not compatible with the json gem., default is false
|
983
983
|
* - *:allow_nan* [_boolean_] If true non JSON compliant words such as Nan and Infinity will be used as appropriate, default is true.
|
984
984
|
* - *:quirks_mode* [_boolean_] Allow single JSON values instead of documents, default is true (allow).
|
985
|
-
* - *:
|
985
|
+
* - *:indent* [_String_|_nil_] String to use for indentation, overriding the indent option if not nil.
|
986
986
|
* - *:space* [_String_|_nil_] String to use for the space after the colon in JSON object fields.
|
987
987
|
* - *:space_before* [_String_|_nil_] String to use before the colon separator in JSON object fields.
|
988
988
|
* - *:object_nl* [_String_|_nil_] String to use after a JSON object field value.
|
@@ -1013,7 +1013,8 @@ to_json(int argc, VALUE *argv, VALUE self) {
|
|
1013
1013
|
// For obj.to_json or generate nan is not allowed but if called from dump
|
1014
1014
|
// it is.
|
1015
1015
|
copts.dump_opts.nan_dump = false;
|
1016
|
-
|
1016
|
+
oj_dump_obj_to_json_using_params(*argv, &copts, &out, argc - 1,argv + 1);
|
1017
|
+
|
1017
1018
|
if (0 == out.buf) {
|
1018
1019
|
rb_raise(rb_eNoMemError, "Not enough memory.");
|
1019
1020
|
}
|
@@ -1456,6 +1457,8 @@ Init_oj() {
|
|
1456
1457
|
rb_define_module_function(Oj, "saj_parse", oj_saj_parse, -1);
|
1457
1458
|
rb_define_module_function(Oj, "sc_parse", oj_sc_parse, -1);
|
1458
1459
|
|
1460
|
+
rb_define_module_function(Oj, "optimize_rails", oj_optimize_rails, 0);
|
1461
|
+
|
1459
1462
|
oj_add_value_id = rb_intern("add_value");
|
1460
1463
|
oj_array_append_id = rb_intern("array_append");
|
1461
1464
|
oj_array_end_id = rb_intern("array_end");
|
data/ext/oj/parse.c
CHANGED
@@ -764,7 +764,7 @@ oj_num_as_value(NumInfo ni) {
|
|
764
764
|
} else {
|
765
765
|
// All these machinations are to get rounding to work better.
|
766
766
|
long double d = (long double)ni->i * (long double)ni->div + (long double)ni->num;
|
767
|
-
int x = ni->exp - ni->di;
|
767
|
+
int x = (int)((int64_t)ni->exp - ni->di);
|
768
768
|
|
769
769
|
// Rounding sometimes cuts off the last digit even if there are only
|
770
770
|
// 15 digits. This attempts to fix those few cases where this
|
data/ext/oj/rails.c
CHANGED
@@ -156,7 +156,7 @@ dump_struct(VALUE obj, int depth, Out out, bool as_ok) {
|
|
156
156
|
*out->cur++ = '{';
|
157
157
|
for (i = 0; i < cnt; i++) {
|
158
158
|
name = rb_id2name(SYM2ID(rb_ary_entry(ma, i)));
|
159
|
-
len = strlen(name);
|
159
|
+
len = (int)strlen(name);
|
160
160
|
assure_size(out, size + sep_len + 6);
|
161
161
|
if (0 < i) {
|
162
162
|
*out->cur++ = ',';
|
@@ -339,13 +339,15 @@ static struct _NamedFunc dump_map[] = {
|
|
339
339
|
};
|
340
340
|
|
341
341
|
static VALUE activerecord_base = Qundef;
|
342
|
+
static ID attributes_id = 0;
|
342
343
|
|
343
344
|
static void
|
344
345
|
dump_activerecord(VALUE obj, int depth, Out out, bool as_ok) {
|
345
|
-
|
346
|
-
|
346
|
+
if (0 == attributes_id) {
|
347
|
+
attributes_id = rb_intern("@attributes");
|
348
|
+
}
|
347
349
|
out->argc = 0;
|
348
|
-
dump_rails_val(
|
350
|
+
dump_rails_val(rb_ivar_get(obj, attributes_id), depth, out, true);
|
349
351
|
}
|
350
352
|
|
351
353
|
static ROpt
|
@@ -822,6 +824,20 @@ rails_set_decoder(VALUE self) {
|
|
822
824
|
return Qnil;
|
823
825
|
}
|
824
826
|
|
827
|
+
/* Document-module: Oj.optimize_rails()
|
828
|
+
*
|
829
|
+
* Sets the Oj as the Rails encoder and decoder. Oj::Rails.optimize is also
|
830
|
+
* called.
|
831
|
+
*/
|
832
|
+
VALUE
|
833
|
+
oj_optimize_rails(VALUE self) {
|
834
|
+
rails_set_encoder(self);
|
835
|
+
rails_set_decoder(self);
|
836
|
+
rails_optimize(0, NULL, self);
|
837
|
+
|
838
|
+
return Qnil;
|
839
|
+
}
|
840
|
+
|
825
841
|
/* Document-module: Oj::Rails
|
826
842
|
*
|
827
843
|
* Module that provides rails and active support compatibility.
|
@@ -855,11 +871,18 @@ static void
|
|
855
871
|
dump_as_json(VALUE obj, int depth, Out out, bool as_ok) {
|
856
872
|
volatile VALUE ja;
|
857
873
|
|
858
|
-
|
859
|
-
|
860
|
-
|
874
|
+
// Some classes elect to not take an options argument so check the arity
|
875
|
+
// of as_json.
|
876
|
+
#if HAS_METHOD_ARITY
|
877
|
+
if (0 == rb_obj_method_arity(obj, oj_as_json_id)) {
|
861
878
|
ja = rb_funcall(obj, oj_as_json_id, 0);
|
879
|
+
} else {
|
880
|
+
ja = rb_funcall2(obj, oj_as_json_id, out->argc, out->argv);
|
862
881
|
}
|
882
|
+
#else
|
883
|
+
ja = rb_funcall2(obj, oj_as_json_id, out->argc, out->argv);
|
884
|
+
#endif
|
885
|
+
|
863
886
|
out->argc = 0;
|
864
887
|
if (ja == obj || !as_ok) {
|
865
888
|
// Once as_json is call it should never be called again on the same
|
data/ext/oj/rails.h
CHANGED
data/ext/oj/rxclass.c
CHANGED
@@ -70,7 +70,7 @@ oj_rxclass_append(RxClass rc, const char *expr, VALUE clas) {
|
|
70
70
|
int flags = 0;
|
71
71
|
#endif
|
72
72
|
if (sizeof(rxc->src) <= strlen(expr)) {
|
73
|
-
snprintf(rc->err, sizeof(rc->err), "expressions must be less than %lu characters", sizeof(rxc->src));
|
73
|
+
snprintf(rc->err, sizeof(rc->err), "expressions must be less than %lu characters", (unsigned long)sizeof(rxc->src));
|
74
74
|
return EINVAL;
|
75
75
|
}
|
76
76
|
rxc = ALLOC_N(struct _RxC, 1);
|
data/lib/oj/version.rb
CHANGED
data/test/test_compat.rb
CHANGED
@@ -29,7 +29,7 @@ class CompatJuice < Minitest::Test
|
|
29
29
|
end
|
30
30
|
alias == eql?
|
31
31
|
|
32
|
-
def to_json()
|
32
|
+
def to_json(*a)
|
33
33
|
%|{"json_class":"#{self.class.to_s}","x":#{@x},"y":#{@y}}|
|
34
34
|
end
|
35
35
|
|
@@ -38,6 +38,15 @@ class CompatJuice < Minitest::Test
|
|
38
38
|
end
|
39
39
|
end # Jeez
|
40
40
|
|
41
|
+
class Argy
|
42
|
+
def initialize()
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_json(*a)
|
46
|
+
%|{"args":"#{a}"}|
|
47
|
+
end
|
48
|
+
end # Argy
|
49
|
+
|
41
50
|
module One
|
42
51
|
module Two
|
43
52
|
module Three
|
@@ -447,6 +456,11 @@ class CompatJuice < Minitest::Test
|
|
447
456
|
assert_equal('"1..7"', json)
|
448
457
|
end
|
449
458
|
|
459
|
+
def test_arg_passing
|
460
|
+
json = Oj.to_json(Argy.new(), :max_nesting=> 40)
|
461
|
+
assert_equal(%|{"args":"[{:max_nesting=>40}]"}|, json)
|
462
|
+
end
|
463
|
+
|
450
464
|
def dump_and_load(obj, trace=false)
|
451
465
|
json = Oj.dump(obj)
|
452
466
|
puts json if trace
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -60,14 +60,14 @@ extensions:
|
|
60
60
|
extra_rdoc_files:
|
61
61
|
- README.md
|
62
62
|
- pages/Advanced.md
|
63
|
-
- pages/Compatibility.md
|
64
|
-
- pages/Custom.md
|
65
63
|
- pages/Encoding.md
|
66
|
-
- pages/JsonGem.md
|
67
64
|
- pages/Modes.md
|
68
|
-
- pages/Options.md
|
69
|
-
- pages/Rails.md
|
70
65
|
- pages/Security.md
|
66
|
+
- pages/JsonGem.md
|
67
|
+
- pages/Rails.md
|
68
|
+
- pages/Compatibility.md
|
69
|
+
- pages/Custom.md
|
70
|
+
- pages/Options.md
|
71
71
|
files:
|
72
72
|
- LICENSE
|
73
73
|
- README.md
|
@@ -239,75 +239,75 @@ signing_key:
|
|
239
239
|
specification_version: 4
|
240
240
|
summary: A fast JSON parser and serializer.
|
241
241
|
test_files:
|
242
|
-
- test/_test_active.rb
|
243
|
-
- test/_test_active_mimic.rb
|
244
|
-
- test/_test_mimic_rails.rb
|
245
|
-
- test/activesupport4/decoding_test.rb
|
246
|
-
- test/activesupport4/encoding_test.rb
|
247
|
-
- test/activesupport4/test_helper.rb
|
248
|
-
- test/activesupport5/decoding_test.rb
|
249
|
-
- test/activesupport5/encoding_test.rb
|
250
|
-
- test/activesupport5/encoding_test_cases.rb
|
251
242
|
- test/activesupport5/test_helper.rb
|
252
243
|
- test/activesupport5/time_zone_test_helpers.rb
|
244
|
+
- test/activesupport5/decoding_test.rb
|
245
|
+
- test/activesupport5/encoding_test_cases.rb
|
246
|
+
- test/activesupport5/encoding_test.rb
|
247
|
+
- test/test_file.rb
|
253
248
|
- test/files.rb
|
254
|
-
- test/helper.rb
|
255
|
-
- test/isolated/shared.rb
|
256
|
-
- test/isolated/test_mimic_after.rb
|
257
|
-
- test/isolated/test_mimic_alone.rb
|
258
|
-
- test/isolated/test_mimic_as_json.rb
|
259
|
-
- test/isolated/test_mimic_before.rb
|
260
|
-
- test/isolated/test_mimic_define.rb
|
261
|
-
- test/isolated/test_mimic_rails_after.rb
|
262
|
-
- test/isolated/test_mimic_rails_before.rb
|
263
|
-
- test/isolated/test_mimic_redefine.rb
|
264
|
-
- test/json_gem/json_addition_test.rb
|
265
|
-
- test/json_gem/json_common_interface_test.rb
|
266
|
-
- test/json_gem/json_encoding_test.rb
|
267
|
-
- test/json_gem/json_ext_parser_test.rb
|
268
|
-
- test/json_gem/json_fixtures_test.rb
|
269
|
-
- test/json_gem/json_generator_test.rb
|
270
|
-
- test/json_gem/json_generic_object_test.rb
|
271
|
-
- test/json_gem/json_parser_test.rb
|
272
|
-
- test/json_gem/json_string_matching_test.rb
|
273
|
-
- test/json_gem/test_helper.rb
|
274
|
-
- test/perf.rb
|
275
|
-
- test/perf_compat.rb
|
276
|
-
- test/perf_fast.rb
|
277
|
-
- test/perf_file.rb
|
278
|
-
- test/perf_object.rb
|
279
|
-
- test/perf_saj.rb
|
280
249
|
- test/perf_scp.rb
|
281
|
-
- test/
|
282
|
-
- test/
|
283
|
-
- test/
|
284
|
-
- test/
|
285
|
-
- test/
|
250
|
+
- test/test_debian.rb
|
251
|
+
- test/test_gc.rb
|
252
|
+
- test/_test_mimic_rails.rb
|
253
|
+
- test/test_writer.rb
|
254
|
+
- test/test_hash.rb
|
286
255
|
- test/sample/file.rb
|
287
|
-
- test/sample/group.rb
|
288
256
|
- test/sample/hasprops.rb
|
289
257
|
- test/sample/layer.rb
|
290
|
-
- test/sample/
|
258
|
+
- test/sample/change.rb
|
259
|
+
- test/sample/doc.rb
|
291
260
|
- test/sample/oval.rb
|
292
|
-
- test/sample/rect.rb
|
293
261
|
- test/sample/shape.rb
|
294
262
|
- test/sample/text.rb
|
295
|
-
- test/sample.rb
|
296
|
-
- test/
|
297
|
-
- test/
|
298
|
-
- test/
|
299
|
-
- test/
|
300
|
-
- test/test_fast.rb
|
301
|
-
- test/test_file.rb
|
302
|
-
- test/test_gc.rb
|
303
|
-
- test/test_hash.rb
|
304
|
-
- test/test_null.rb
|
263
|
+
- test/sample/group.rb
|
264
|
+
- test/sample/dir.rb
|
265
|
+
- test/sample/line.rb
|
266
|
+
- test/sample/rect.rb
|
267
|
+
- test/tests.rb
|
305
268
|
- test/test_object.rb
|
269
|
+
- test/tests_mimic.rb
|
270
|
+
- test/perf_saj.rb
|
271
|
+
- test/tests_mimic_addition.rb
|
306
272
|
- test/test_saj.rb
|
273
|
+
- test/sample.rb
|
307
274
|
- test/test_scp.rb
|
308
|
-
- test/
|
275
|
+
- test/perf_object.rb
|
276
|
+
- test/perf_simple.rb
|
277
|
+
- test/test_null.rb
|
278
|
+
- test/_test_active_mimic.rb
|
279
|
+
- test/_test_active.rb
|
280
|
+
- test/test_compat.rb
|
281
|
+
- test/sample_json.rb
|
282
|
+
- test/json_gem/test_helper.rb
|
283
|
+
- test/json_gem/json_generic_object_test.rb
|
284
|
+
- test/json_gem/json_common_interface_test.rb
|
285
|
+
- test/json_gem/json_string_matching_test.rb
|
286
|
+
- test/json_gem/json_addition_test.rb
|
287
|
+
- test/json_gem/json_fixtures_test.rb
|
288
|
+
- test/json_gem/json_generator_test.rb
|
289
|
+
- test/json_gem/json_ext_parser_test.rb
|
290
|
+
- test/json_gem/json_parser_test.rb
|
291
|
+
- test/json_gem/json_encoding_test.rb
|
292
|
+
- test/helper.rb
|
293
|
+
- test/activesupport4/test_helper.rb
|
294
|
+
- test/activesupport4/decoding_test.rb
|
295
|
+
- test/activesupport4/encoding_test.rb
|
296
|
+
- test/perf_file.rb
|
297
|
+
- test/perf_compat.rb
|
309
298
|
- test/test_various.rb
|
310
|
-
- test/
|
311
|
-
- test/
|
312
|
-
- test/
|
313
|
-
- test/
|
299
|
+
- test/test_strict.rb
|
300
|
+
- test/test_custom.rb
|
301
|
+
- test/perf_strict.rb
|
302
|
+
- test/perf_fast.rb
|
303
|
+
- test/isolated/test_mimic_alone.rb
|
304
|
+
- test/isolated/test_mimic_after.rb
|
305
|
+
- test/isolated/test_mimic_as_json.rb
|
306
|
+
- test/isolated/test_mimic_rails_after.rb
|
307
|
+
- test/isolated/test_mimic_before.rb
|
308
|
+
- test/isolated/test_mimic_rails_before.rb
|
309
|
+
- test/isolated/test_mimic_define.rb
|
310
|
+
- test/isolated/shared.rb
|
311
|
+
- test/isolated/test_mimic_redefine.rb
|
312
|
+
- test/perf.rb
|
313
|
+
- test/test_fast.rb
|