oj 3.7.4 → 3.13.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1352 -0
- data/README.md +29 -8
- data/RELEASE_NOTES.md +61 -0
- data/ext/oj/buf.h +53 -72
- data/ext/oj/cache.c +326 -0
- data/ext/oj/cache.h +21 -0
- data/ext/oj/cache8.c +61 -64
- data/ext/oj/cache8.h +12 -39
- data/ext/oj/circarray.c +37 -43
- data/ext/oj/circarray.h +16 -17
- data/ext/oj/code.c +165 -179
- data/ext/oj/code.h +27 -29
- data/ext/oj/compat.c +174 -194
- data/ext/oj/custom.c +809 -866
- data/ext/oj/debug.c +132 -0
- data/ext/oj/dump.c +848 -863
- data/ext/oj/dump.h +81 -67
- data/ext/oj/dump_compat.c +85 -123
- data/ext/oj/dump_leaf.c +100 -188
- data/ext/oj/dump_object.c +527 -656
- data/ext/oj/dump_strict.c +315 -338
- data/ext/oj/encode.h +7 -34
- data/ext/oj/encoder.c +43 -0
- data/ext/oj/err.c +40 -29
- data/ext/oj/err.h +48 -48
- data/ext/oj/extconf.rb +17 -4
- data/ext/oj/fast.c +1070 -1087
- data/ext/oj/intern.c +301 -0
- data/ext/oj/intern.h +26 -0
- data/ext/oj/mimic_json.c +469 -436
- data/ext/oj/object.c +525 -593
- data/ext/oj/odd.c +154 -138
- data/ext/oj/odd.h +37 -38
- data/ext/oj/oj.c +1325 -986
- data/ext/oj/oj.h +333 -316
- data/ext/oj/parse.c +1002 -846
- data/ext/oj/parse.h +92 -87
- data/ext/oj/parser.c +1557 -0
- data/ext/oj/parser.h +91 -0
- data/ext/oj/rails.c +888 -878
- data/ext/oj/rails.h +11 -14
- data/ext/oj/reader.c +141 -147
- data/ext/oj/reader.h +73 -89
- data/ext/oj/resolve.c +41 -62
- data/ext/oj/resolve.h +7 -9
- data/ext/oj/rxclass.c +71 -75
- data/ext/oj/rxclass.h +18 -19
- data/ext/oj/saj.c +443 -486
- data/ext/oj/saj2.c +602 -0
- data/ext/oj/scp.c +88 -113
- data/ext/oj/sparse.c +787 -709
- data/ext/oj/stream_writer.c +133 -159
- data/ext/oj/strict.c +127 -118
- data/ext/oj/string_writer.c +230 -249
- data/ext/oj/trace.c +34 -41
- data/ext/oj/trace.h +19 -19
- data/ext/oj/usual.c +1254 -0
- data/ext/oj/util.c +136 -0
- data/ext/oj/util.h +20 -0
- data/ext/oj/val_stack.c +59 -67
- data/ext/oj/val_stack.h +91 -129
- data/ext/oj/validate.c +46 -0
- data/ext/oj/wab.c +342 -353
- data/lib/oj/bag.rb +1 -0
- data/lib/oj/easy_hash.rb +5 -4
- data/lib/oj/error.rb +1 -1
- data/lib/oj/json.rb +1 -1
- data/lib/oj/mimic.rb +48 -14
- data/lib/oj/saj.rb +20 -6
- data/lib/oj/state.rb +8 -7
- data/lib/oj/version.rb +2 -2
- data/lib/oj.rb +0 -8
- data/pages/Compatibility.md +1 -1
- data/pages/JsonGem.md +15 -0
- data/pages/Modes.md +53 -46
- data/pages/Options.md +72 -11
- data/pages/Parser.md +309 -0
- data/pages/Rails.md +73 -22
- data/pages/Security.md +1 -1
- data/test/activerecord/result_test.rb +7 -2
- data/test/activesupport5/abstract_unit.rb +45 -0
- data/test/activesupport5/decoding_test.rb +68 -60
- data/test/activesupport5/encoding_test.rb +111 -96
- data/test/activesupport5/encoding_test_cases.rb +33 -25
- data/test/activesupport5/test_helper.rb +43 -21
- data/test/activesupport5/time_zone_test_helpers.rb +18 -3
- data/test/activesupport6/abstract_unit.rb +44 -0
- data/test/activesupport6/decoding_test.rb +133 -0
- data/test/activesupport6/encoding_test.rb +507 -0
- data/test/activesupport6/encoding_test_cases.rb +98 -0
- data/test/activesupport6/test_common.rb +17 -0
- data/test/activesupport6/test_helper.rb +163 -0
- data/test/activesupport6/time_zone_test_helpers.rb +39 -0
- data/test/activesupport7/abstract_unit.rb +49 -0
- data/test/activesupport7/decoding_test.rb +125 -0
- data/test/activesupport7/encoding_test.rb +486 -0
- data/test/activesupport7/encoding_test_cases.rb +104 -0
- data/test/activesupport7/time_zone_test_helpers.rb +47 -0
- data/test/bar.rb +6 -12
- data/test/baz.rb +16 -0
- data/test/bug.rb +16 -0
- data/test/foo.rb +69 -75
- data/test/helper.rb +16 -0
- data/test/json_gem/json_common_interface_test.rb +8 -3
- data/test/json_gem/json_generator_test.rb +18 -4
- data/test/json_gem/json_parser_test.rb +9 -0
- data/test/json_gem/test_helper.rb +12 -0
- data/test/mem.rb +33 -0
- data/test/perf.rb +1 -1
- data/test/perf_dump.rb +50 -0
- data/test/perf_once.rb +58 -0
- data/test/perf_parser.rb +189 -0
- data/test/perf_scp.rb +11 -10
- data/test/perf_strict.rb +17 -23
- data/test/prec.rb +23 -0
- data/test/sample_json.rb +1 -1
- data/test/test_compat.rb +46 -10
- data/test/test_custom.rb +147 -8
- data/test/test_fast.rb +62 -2
- data/test/test_file.rb +25 -2
- data/test/test_gc.rb +13 -0
- data/test/test_generate.rb +21 -0
- data/test/test_hash.rb +11 -1
- data/test/test_integer_range.rb +7 -2
- data/test/test_object.rb +85 -9
- data/test/test_parser.rb +27 -0
- data/test/test_parser_saj.rb +335 -0
- data/test/test_parser_usual.rb +217 -0
- data/test/test_rails.rb +35 -0
- data/test/test_saj.rb +1 -1
- data/test/test_scp.rb +5 -5
- data/test/test_strict.rb +26 -1
- data/test/test_various.rb +87 -65
- data/test/test_wab.rb +2 -0
- data/test/test_writer.rb +19 -2
- data/test/tests.rb +1 -1
- data/test/zoo.rb +13 -0
- metadata +60 -110
- data/ext/oj/hash.c +0 -163
- data/ext/oj/hash.h +0 -46
- data/ext/oj/hash_test.c +0 -512
data/ext/oj/compat.c
CHANGED
@@ -1,298 +1,278 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
* All rights reserved.
|
4
|
-
*/
|
1
|
+
// Copyright (c) 2012 Peter Ohler. All rights reserved.
|
2
|
+
// Licensed under the MIT License. See LICENSE file in the project root for license details.
|
5
3
|
|
6
4
|
#include <stdio.h>
|
7
5
|
|
8
|
-
#include "
|
6
|
+
#include "encode.h"
|
9
7
|
#include "err.h"
|
8
|
+
#include "intern.h"
|
9
|
+
#include "oj.h"
|
10
10
|
#include "parse.h"
|
11
11
|
#include "resolve.h"
|
12
|
-
#include "hash.h"
|
13
|
-
#include "encode.h"
|
14
12
|
#include "trace.h"
|
15
13
|
|
16
|
-
static void
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
(int)pi->options.create_id_len == klen &&
|
28
|
-
0 == strncmp(pi->options.create_id, key, klen)) {
|
29
|
-
|
30
|
-
parent->classname = oj_strndup(str, len);
|
31
|
-
parent->clen = len;
|
14
|
+
static void hash_set_cstr(ParseInfo pi, Val kval, const char *str, size_t len, const char *orig) {
|
15
|
+
const char * key = kval->key;
|
16
|
+
int klen = kval->klen;
|
17
|
+
Val parent = stack_peek(&pi->stack);
|
18
|
+
volatile VALUE rkey = kval->key_val;
|
19
|
+
|
20
|
+
if (Qundef == rkey && Yes == pi->options.create_ok && NULL != pi->options.create_id &&
|
21
|
+
*pi->options.create_id == *key && (int)pi->options.create_id_len == klen &&
|
22
|
+
0 == strncmp(pi->options.create_id, key, klen)) {
|
23
|
+
parent->classname = oj_strndup(str, len);
|
24
|
+
parent->clen = len;
|
32
25
|
} else {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
26
|
+
volatile VALUE rstr = oj_cstr_to_value(str, len, (size_t)pi->options.cache_str);
|
27
|
+
|
28
|
+
if (Qundef == rkey) {
|
29
|
+
if (Yes != pi->options.cache_keys) {
|
30
|
+
if (Yes == pi->options.sym_key) {
|
31
|
+
rkey = ID2SYM(rb_intern3(key, klen, oj_utf8_encoding));
|
32
|
+
} else {
|
33
|
+
rkey = rb_utf8_str_new(key, klen);
|
34
|
+
}
|
35
|
+
} else if (Yes == pi->options.sym_key) {
|
36
|
+
rkey = oj_sym_intern(key, klen);
|
37
|
+
} else {
|
38
|
+
rkey = oj_str_intern(key, klen);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
42
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
43
|
+
|
44
|
+
if (Qnil != clas) {
|
45
|
+
rstr = rb_funcall(clas, oj_json_create_id, 1, rstr);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
if (rb_cHash != rb_obj_class(parent->val)) {
|
49
|
+
// The rb_hash_set would still work but the unit tests for the
|
50
|
+
// json gem require the less efficient []= method be called to set
|
51
|
+
// values. Even using the store method to set the values will fail
|
52
|
+
// the unit tests.
|
53
|
+
rb_funcall(parent->val, rb_intern("[]="), 2, rkey, rstr);
|
54
|
+
} else {
|
55
|
+
rb_hash_aset(parent->val, rkey, rstr);
|
56
|
+
}
|
57
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
58
|
+
oj_trace_parse_call("set_string", pi, __FILE__, __LINE__, rstr);
|
59
|
+
}
|
62
60
|
}
|
63
61
|
}
|
64
62
|
|
65
|
-
static VALUE
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
static VALUE start_hash(ParseInfo pi) {
|
64
|
+
volatile VALUE h;
|
65
|
+
|
69
66
|
if (Qnil != pi->options.hash_class) {
|
70
|
-
|
67
|
+
h = rb_class_new_instance(0, NULL, pi->options.hash_class);
|
71
68
|
} else {
|
72
|
-
|
69
|
+
h = rb_hash_new();
|
73
70
|
}
|
74
|
-
if (Yes == pi->options.trace) {
|
75
|
-
|
71
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
72
|
+
oj_trace_parse_in("start_hash", pi, __FILE__, __LINE__);
|
76
73
|
}
|
77
74
|
return h;
|
78
75
|
}
|
79
76
|
|
80
|
-
static void
|
81
|
-
|
82
|
-
Val parent = stack_peek(&pi->stack);
|
77
|
+
static void end_hash(struct _parseInfo *pi) {
|
78
|
+
Val parent = stack_peek(&pi->stack);
|
83
79
|
|
84
80
|
if (0 != parent->classname) {
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
81
|
+
volatile VALUE clas;
|
82
|
+
|
83
|
+
clas = oj_name2class(pi, parent->classname, parent->clen, 0, rb_eArgError);
|
84
|
+
if (Qundef != clas) { // else an error
|
85
|
+
ID creatable = rb_intern("json_creatable?");
|
86
|
+
|
87
|
+
if (!rb_respond_to(clas, creatable) || Qtrue == rb_funcall(clas, creatable, 0)) {
|
88
|
+
parent->val = rb_funcall(clas, oj_json_create_id, 1, parent->val);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
if (0 != parent->classname) {
|
92
|
+
xfree((char *)parent->classname);
|
93
|
+
parent->classname = 0;
|
94
|
+
}
|
99
95
|
}
|
100
|
-
if (Yes == pi->options.trace) {
|
101
|
-
|
96
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
97
|
+
oj_trace_parse_hash_end(pi, __FILE__, __LINE__);
|
102
98
|
}
|
103
99
|
}
|
104
100
|
|
105
|
-
static
|
106
|
-
|
107
|
-
volatile VALUE rkey = parent->key_val;
|
101
|
+
static void add_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) {
|
102
|
+
volatile VALUE rstr = oj_cstr_to_value(str, len, (size_t)pi->options.cache_str);
|
108
103
|
|
109
|
-
if (Qundef == rkey) {
|
110
|
-
rkey = rb_str_new(parent->key, parent->klen);
|
111
|
-
}
|
112
|
-
rkey = oj_encode(rkey);
|
113
|
-
if (Yes == pi->options.sym_key) {
|
114
|
-
rkey = rb_str_intern(rkey);
|
115
|
-
}
|
116
|
-
return rkey;
|
117
|
-
}
|
118
|
-
|
119
|
-
static void
|
120
|
-
add_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) {
|
121
|
-
volatile VALUE rstr = rb_str_new(str, len);
|
122
|
-
|
123
|
-
rstr = oj_encode(rstr);
|
124
104
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
125
|
-
|
105
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
126
106
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
107
|
+
if (Qnil != clas) {
|
108
|
+
pi->stack.head->val = rb_funcall(clas, oj_json_create_id, 1, rstr);
|
109
|
+
return;
|
110
|
+
}
|
131
111
|
}
|
132
112
|
pi->stack.head->val = rstr;
|
133
|
-
if (Yes == pi->options.trace) {
|
134
|
-
|
113
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
114
|
+
oj_trace_parse_call("add_string", pi, __FILE__, __LINE__, rstr);
|
135
115
|
}
|
136
116
|
}
|
137
117
|
|
138
|
-
static void
|
139
|
-
add_num(ParseInfo pi, NumInfo ni) {
|
118
|
+
static void add_num(ParseInfo pi, NumInfo ni) {
|
140
119
|
pi->stack.head->val = oj_num_as_value(ni);
|
141
|
-
if (Yes == pi->options.trace) {
|
142
|
-
|
120
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
121
|
+
oj_trace_parse_call("add_number", pi, __FILE__, __LINE__, pi->stack.head->val);
|
143
122
|
}
|
144
123
|
}
|
145
124
|
|
146
|
-
static void
|
147
|
-
|
148
|
-
|
149
|
-
|
125
|
+
static void hash_set_num(struct _parseInfo *pi, Val parent, NumInfo ni) {
|
126
|
+
volatile VALUE rval = oj_num_as_value(ni);
|
127
|
+
|
150
128
|
if (!oj_use_hash_alt && rb_cHash != rb_obj_class(parent->val)) {
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
129
|
+
// The rb_hash_set would still work but the unit tests for the
|
130
|
+
// json gem require the less efficient []= method be called to set
|
131
|
+
// values. Even using the store method to set the values will fail
|
132
|
+
// the unit tests.
|
133
|
+
rb_funcall(stack_peek(&pi->stack)->val,
|
134
|
+
rb_intern("[]="),
|
135
|
+
2,
|
136
|
+
oj_calc_hash_key(pi, parent),
|
137
|
+
rval);
|
156
138
|
} else {
|
157
|
-
|
139
|
+
rb_hash_aset(stack_peek(&pi->stack)->val, oj_calc_hash_key(pi, parent), rval);
|
158
140
|
}
|
159
|
-
if (Yes == pi->options.trace) {
|
160
|
-
|
141
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
142
|
+
oj_trace_parse_call("set_number", pi, __FILE__, __LINE__, rval);
|
161
143
|
}
|
162
144
|
}
|
163
145
|
|
164
|
-
static void
|
165
|
-
hash_set_value(ParseInfo pi, Val parent, VALUE value) {
|
146
|
+
static void hash_set_value(ParseInfo pi, Val parent, VALUE value) {
|
166
147
|
if (rb_cHash != rb_obj_class(parent->val)) {
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
148
|
+
// The rb_hash_set would still work but the unit tests for the
|
149
|
+
// json gem require the less efficient []= method be called to set
|
150
|
+
// values. Even using the store method to set the values will fail
|
151
|
+
// the unit tests.
|
152
|
+
rb_funcall(stack_peek(&pi->stack)->val,
|
153
|
+
rb_intern("[]="),
|
154
|
+
2,
|
155
|
+
oj_calc_hash_key(pi, parent),
|
156
|
+
value);
|
172
157
|
} else {
|
173
|
-
|
158
|
+
rb_hash_aset(stack_peek(&pi->stack)->val, oj_calc_hash_key(pi, parent), value);
|
174
159
|
}
|
175
|
-
if (Yes == pi->options.trace) {
|
176
|
-
|
160
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
161
|
+
oj_trace_parse_call("set_value", pi, __FILE__, __LINE__, value);
|
177
162
|
}
|
178
163
|
}
|
179
164
|
|
180
|
-
static VALUE
|
181
|
-
start_array(ParseInfo pi) {
|
165
|
+
static VALUE start_array(ParseInfo pi) {
|
182
166
|
if (Qnil != pi->options.array_class) {
|
183
|
-
|
167
|
+
return rb_class_new_instance(0, NULL, pi->options.array_class);
|
184
168
|
}
|
185
|
-
if (Yes == pi->options.trace) {
|
186
|
-
|
169
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
170
|
+
oj_trace_parse_in("start_array", pi, __FILE__, __LINE__);
|
187
171
|
}
|
188
172
|
return rb_ary_new();
|
189
173
|
}
|
190
174
|
|
191
|
-
static void
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
175
|
+
static void array_append_num(ParseInfo pi, NumInfo ni) {
|
176
|
+
Val parent = stack_peek(&pi->stack);
|
177
|
+
volatile VALUE rval = oj_num_as_value(ni);
|
178
|
+
|
196
179
|
if (!oj_use_array_alt && rb_cArray != rb_obj_class(parent->val)) {
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
180
|
+
// The rb_ary_push would still work but the unit tests for the json
|
181
|
+
// gem require the less efficient << method be called to push the
|
182
|
+
// values.
|
183
|
+
rb_funcall(parent->val, rb_intern("<<"), 1, rval);
|
201
184
|
} else {
|
202
|
-
|
185
|
+
rb_ary_push(parent->val, rval);
|
203
186
|
}
|
204
|
-
if (Yes == pi->options.trace) {
|
205
|
-
|
187
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
188
|
+
oj_trace_parse_call("append_number", pi, __FILE__, __LINE__, rval);
|
206
189
|
}
|
207
190
|
}
|
208
191
|
|
209
|
-
static void
|
210
|
-
|
211
|
-
volatile VALUE rstr = rb_str_new(str, len);
|
192
|
+
static void array_append_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) {
|
193
|
+
volatile VALUE rstr = oj_cstr_to_value(str, len, (size_t)pi->options.cache_str);
|
212
194
|
|
213
|
-
rstr = oj_encode(rstr);
|
214
195
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
215
|
-
|
196
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
216
197
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
198
|
+
if (Qnil != clas) {
|
199
|
+
rb_ary_push(stack_peek(&pi->stack)->val, rb_funcall(clas, oj_json_create_id, 1, rstr));
|
200
|
+
return;
|
201
|
+
}
|
221
202
|
}
|
222
203
|
rb_ary_push(stack_peek(&pi->stack)->val, rstr);
|
223
|
-
if (Yes == pi->options.trace) {
|
224
|
-
|
204
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
205
|
+
oj_trace_parse_call("append_string", pi, __FILE__, __LINE__, rstr);
|
225
206
|
}
|
226
207
|
}
|
227
208
|
|
228
|
-
void
|
229
|
-
oj_set_compat_callbacks(ParseInfo pi) {
|
209
|
+
void oj_set_compat_callbacks(ParseInfo pi) {
|
230
210
|
oj_set_strict_callbacks(pi);
|
231
|
-
pi->start_hash
|
232
|
-
pi->end_hash
|
233
|
-
pi->hash_set_cstr
|
234
|
-
pi->hash_set_num
|
235
|
-
pi->hash_set_value
|
236
|
-
pi->add_num
|
237
|
-
pi->add_cstr
|
211
|
+
pi->start_hash = start_hash;
|
212
|
+
pi->end_hash = end_hash;
|
213
|
+
pi->hash_set_cstr = hash_set_cstr;
|
214
|
+
pi->hash_set_num = hash_set_num;
|
215
|
+
pi->hash_set_value = hash_set_value;
|
216
|
+
pi->add_num = add_num;
|
217
|
+
pi->add_cstr = add_cstr;
|
238
218
|
pi->array_append_cstr = array_append_cstr;
|
239
|
-
pi->start_array
|
240
|
-
pi->array_append_num
|
219
|
+
pi->start_array = start_array;
|
220
|
+
pi->array_append_num = array_append_num;
|
241
221
|
}
|
242
222
|
|
243
223
|
VALUE
|
244
224
|
oj_compat_parse(int argc, VALUE *argv, VALUE self) {
|
245
|
-
struct
|
225
|
+
struct _parseInfo pi;
|
246
226
|
|
247
227
|
parse_info_init(&pi);
|
248
|
-
pi.options
|
249
|
-
pi.handler
|
250
|
-
pi.err_class
|
251
|
-
pi.max_depth
|
252
|
-
pi.options.allow_nan
|
253
|
-
pi.options.nilnil
|
228
|
+
pi.options = oj_default_options;
|
229
|
+
pi.handler = Qnil;
|
230
|
+
pi.err_class = Qnil;
|
231
|
+
pi.max_depth = 0;
|
232
|
+
pi.options.allow_nan = Yes;
|
233
|
+
pi.options.nilnil = Yes;
|
254
234
|
pi.options.empty_string = No;
|
255
235
|
oj_set_compat_callbacks(&pi);
|
256
236
|
|
257
237
|
if (T_STRING == rb_type(*argv)) {
|
258
|
-
|
238
|
+
return oj_pi_parse(argc, argv, &pi, 0, 0, false);
|
259
239
|
} else {
|
260
|
-
|
240
|
+
return oj_pi_sparse(argc, argv, &pi, 0);
|
261
241
|
}
|
262
242
|
}
|
263
243
|
|
264
244
|
VALUE
|
265
245
|
oj_compat_load(int argc, VALUE *argv, VALUE self) {
|
266
|
-
struct
|
246
|
+
struct _parseInfo pi;
|
267
247
|
|
268
248
|
parse_info_init(&pi);
|
269
|
-
pi.options
|
270
|
-
pi.handler
|
271
|
-
pi.err_class
|
272
|
-
pi.max_depth
|
273
|
-
pi.options.allow_nan
|
274
|
-
pi.options.nilnil
|
249
|
+
pi.options = oj_default_options;
|
250
|
+
pi.handler = Qnil;
|
251
|
+
pi.err_class = Qnil;
|
252
|
+
pi.max_depth = 0;
|
253
|
+
pi.options.allow_nan = Yes;
|
254
|
+
pi.options.nilnil = Yes;
|
275
255
|
pi.options.empty_string = Yes;
|
276
256
|
oj_set_compat_callbacks(&pi);
|
277
|
-
|
257
|
+
|
278
258
|
if (T_STRING == rb_type(*argv)) {
|
279
|
-
|
259
|
+
return oj_pi_parse(argc, argv, &pi, 0, 0, false);
|
280
260
|
} else {
|
281
|
-
|
261
|
+
return oj_pi_sparse(argc, argv, &pi, 0);
|
282
262
|
}
|
283
263
|
}
|
284
264
|
|
285
265
|
VALUE
|
286
266
|
oj_compat_parse_cstr(int argc, VALUE *argv, char *json, size_t len) {
|
287
|
-
struct
|
267
|
+
struct _parseInfo pi;
|
288
268
|
|
289
269
|
parse_info_init(&pi);
|
290
|
-
pi.options
|
291
|
-
pi.handler
|
292
|
-
pi.err_class
|
293
|
-
pi.max_depth
|
270
|
+
pi.options = oj_default_options;
|
271
|
+
pi.handler = Qnil;
|
272
|
+
pi.err_class = Qnil;
|
273
|
+
pi.max_depth = 0;
|
294
274
|
pi.options.allow_nan = Yes;
|
295
|
-
pi.options.nilnil
|
275
|
+
pi.options.nilnil = Yes;
|
296
276
|
oj_set_compat_callbacks(&pi);
|
297
277
|
|
298
278
|
return oj_pi_parse(argc, argv, &pi, json, len, false);
|