oj 3.11.0 → 3.16.5
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/CHANGELOG.md +1421 -0
- data/README.md +20 -5
- data/RELEASE_NOTES.md +61 -0
- data/ext/oj/buf.h +48 -38
- data/ext/oj/cache.c +329 -0
- data/ext/oj/cache.h +22 -0
- data/ext/oj/cache8.c +60 -62
- data/ext/oj/cache8.h +8 -7
- data/ext/oj/circarray.c +35 -35
- data/ext/oj/circarray.h +11 -9
- data/ext/oj/code.c +156 -174
- data/ext/oj/code.h +19 -18
- data/ext/oj/compat.c +140 -197
- data/ext/oj/custom.c +737 -879
- data/ext/oj/debug.c +126 -0
- data/ext/oj/dump.c +830 -835
- data/ext/oj/dump.h +65 -53
- data/ext/oj/dump_compat.c +566 -642
- data/ext/oj/dump_leaf.c +95 -182
- data/ext/oj/dump_object.c +518 -659
- data/ext/oj/dump_strict.c +301 -334
- data/ext/oj/encode.h +3 -4
- data/ext/oj/encoder.c +43 -0
- data/ext/oj/err.c +27 -24
- data/ext/oj/err.h +38 -13
- data/ext/oj/extconf.rb +23 -7
- data/ext/oj/fast.c +1043 -1073
- data/ext/oj/intern.c +313 -0
- data/ext/oj/intern.h +22 -0
- data/ext/oj/mem.c +318 -0
- data/ext/oj/mem.h +53 -0
- data/ext/oj/mimic_json.c +449 -423
- data/ext/oj/object.c +530 -576
- data/ext/oj/odd.c +155 -138
- data/ext/oj/odd.h +24 -22
- data/ext/oj/oj.c +1331 -993
- data/ext/oj/oj.h +306 -292
- data/ext/oj/parse.c +934 -938
- data/ext/oj/parse.h +73 -70
- data/ext/oj/parser.c +1600 -0
- data/ext/oj/parser.h +101 -0
- data/ext/oj/rails.c +795 -845
- data/ext/oj/rails.h +7 -7
- data/ext/oj/reader.c +132 -140
- data/ext/oj/reader.h +67 -78
- data/ext/oj/resolve.c +40 -59
- data/ext/oj/resolve.h +3 -2
- data/ext/oj/rxclass.c +67 -67
- data/ext/oj/rxclass.h +11 -9
- data/ext/oj/saj.c +441 -480
- data/ext/oj/saj2.c +584 -0
- data/ext/oj/saj2.h +23 -0
- data/ext/oj/scp.c +78 -111
- data/ext/oj/sparse.c +726 -730
- data/ext/oj/stream_writer.c +146 -165
- data/ext/oj/strict.c +103 -123
- data/ext/oj/string_writer.c +241 -253
- data/ext/oj/trace.c +29 -33
- data/ext/oj/trace.h +41 -11
- data/ext/oj/usual.c +1218 -0
- data/ext/oj/usual.h +69 -0
- data/ext/oj/util.c +103 -103
- data/ext/oj/util.h +3 -2
- data/ext/oj/val_stack.c +60 -49
- data/ext/oj/val_stack.h +79 -85
- data/ext/oj/validate.c +46 -0
- data/ext/oj/wab.c +307 -350
- data/lib/oj/active_support_helper.rb +1 -3
- data/lib/oj/bag.rb +8 -1
- data/lib/oj/easy_hash.rb +9 -9
- data/lib/oj/error.rb +1 -2
- data/lib/oj/json.rb +162 -150
- data/lib/oj/mimic.rb +9 -19
- data/lib/oj/saj.rb +20 -6
- data/lib/oj/schandler.rb +5 -4
- data/lib/oj/state.rb +12 -8
- data/lib/oj/version.rb +1 -2
- data/lib/oj.rb +2 -0
- data/pages/Compatibility.md +1 -1
- data/pages/InstallOptions.md +20 -0
- data/pages/JsonGem.md +15 -0
- data/pages/Modes.md +8 -3
- data/pages/Options.md +43 -5
- data/pages/Parser.md +309 -0
- data/pages/Rails.md +14 -2
- data/test/_test_active.rb +8 -9
- data/test/_test_active_mimic.rb +7 -8
- data/test/_test_mimic_rails.rb +17 -20
- data/test/activerecord/result_test.rb +12 -8
- data/test/activesupport6/encoding_test.rb +63 -28
- data/test/{activesupport5 → activesupport7}/abstract_unit.rb +16 -12
- data/test/{activesupport5 → activesupport7}/decoding_test.rb +2 -10
- data/test/{activesupport5 → activesupport7}/encoding_test.rb +86 -50
- data/test/{activesupport5 → activesupport7}/encoding_test_cases.rb +6 -0
- data/test/{activesupport5 → activesupport7}/time_zone_test_helpers.rb +8 -0
- data/test/files.rb +15 -15
- data/test/foo.rb +17 -43
- data/test/helper.rb +16 -3
- data/test/isolated/shared.rb +3 -2
- data/test/json_gem/json_addition_test.rb +2 -2
- data/test/json_gem/json_common_interface_test.rb +8 -6
- data/test/json_gem/json_encoding_test.rb +0 -0
- data/test/json_gem/json_ext_parser_test.rb +1 -0
- data/test/json_gem/json_fixtures_test.rb +3 -2
- data/test/json_gem/json_generator_test.rb +71 -41
- data/test/json_gem/json_generic_object_test.rb +11 -11
- data/test/json_gem/json_parser_test.rb +54 -47
- data/test/json_gem/json_string_matching_test.rb +9 -9
- data/test/json_gem/test_helper.rb +12 -0
- data/test/mem.rb +34 -0
- data/test/perf.rb +22 -27
- data/test/perf_compat.rb +31 -33
- data/test/perf_dump.rb +50 -0
- data/test/perf_fast.rb +80 -82
- data/test/perf_file.rb +27 -29
- data/test/perf_object.rb +65 -69
- data/test/perf_once.rb +59 -0
- data/test/perf_parser.rb +183 -0
- data/test/perf_saj.rb +46 -54
- data/test/perf_scp.rb +58 -69
- data/test/perf_simple.rb +41 -39
- data/test/perf_strict.rb +74 -82
- data/test/perf_wab.rb +67 -69
- data/test/prec.rb +5 -5
- data/test/sample/change.rb +0 -1
- data/test/sample/dir.rb +0 -1
- data/test/sample/doc.rb +0 -1
- data/test/sample/file.rb +0 -1
- data/test/sample/group.rb +0 -1
- data/test/sample/hasprops.rb +0 -1
- data/test/sample/layer.rb +0 -1
- data/test/sample/rect.rb +0 -1
- data/test/sample/shape.rb +0 -1
- data/test/sample/text.rb +0 -1
- data/test/sample.rb +16 -16
- data/test/sample_json.rb +8 -8
- data/test/test_compat.rb +97 -45
- data/test/test_custom.rb +73 -51
- data/test/test_debian.rb +7 -10
- data/test/test_fast.rb +135 -79
- data/test/test_file.rb +41 -30
- data/test/test_gc.rb +16 -5
- data/test/test_generate.rb +21 -0
- data/test/test_hash.rb +15 -5
- data/test/test_integer_range.rb +9 -9
- data/test/test_null.rb +20 -20
- data/test/test_object.rb +99 -96
- data/test/test_parser.rb +11 -0
- data/test/test_parser_debug.rb +27 -0
- data/test/test_parser_saj.rb +337 -0
- data/test/test_parser_usual.rb +251 -0
- data/test/test_rails.rb +2 -2
- data/test/test_saj.rb +10 -8
- data/test/test_scp.rb +38 -40
- data/test/test_strict.rb +40 -32
- data/test/test_various.rb +165 -84
- data/test/test_wab.rb +48 -44
- data/test/test_writer.rb +47 -47
- data/test/tests.rb +13 -5
- data/test/tests_mimic.rb +12 -3
- data/test/tests_mimic_addition.rb +12 -3
- metadata +75 -127
- data/ext/oj/hash.c +0 -135
- data/ext/oj/hash.h +0 -18
- data/ext/oj/hash_test.c +0 -484
- data/test/activesupport4/decoding_test.rb +0 -108
- data/test/activesupport4/encoding_test.rb +0 -531
- data/test/activesupport4/test_helper.rb +0 -41
- data/test/activesupport5/test_helper.rb +0 -72
- data/test/bar.rb +0 -35
- data/test/baz.rb +0 -16
- data/test/zoo.rb +0 -13
data/ext/oj/compat.c
CHANGED
@@ -1,295 +1,238 @@
|
|
1
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.
|
2
3
|
|
3
4
|
#include <stdio.h>
|
4
5
|
|
5
|
-
#include "
|
6
|
+
#include "encode.h"
|
6
7
|
#include "err.h"
|
8
|
+
#include "intern.h"
|
9
|
+
#include "mem.h"
|
10
|
+
#include "oj.h"
|
7
11
|
#include "parse.h"
|
8
12
|
#include "resolve.h"
|
9
|
-
#include "hash.h"
|
10
|
-
#include "encode.h"
|
11
13
|
#include "trace.h"
|
12
14
|
|
13
|
-
static void
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
*pi->options.create_id == *key &&
|
24
|
-
(int)pi->options.create_id_len == klen &&
|
25
|
-
0 == strncmp(pi->options.create_id, key, klen)) {
|
26
|
-
|
27
|
-
parent->classname = oj_strndup(str, len);
|
28
|
-
parent->clen = len;
|
15
|
+
static void hash_set_cstr(ParseInfo pi, Val kval, const char *str, size_t len, const char *orig) {
|
16
|
+
const char *key = kval->key;
|
17
|
+
int klen = kval->klen;
|
18
|
+
Val parent = stack_peek(&pi->stack);
|
19
|
+
|
20
|
+
if (Qundef == kval->key_val && 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;
|
29
25
|
} else {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
// values. Even using the store method to set the values will fail
|
51
|
-
// the unit tests.
|
52
|
-
rb_funcall(parent->val, rb_intern("[]="), 2, rkey, rstr);
|
53
|
-
} else {
|
54
|
-
rb_hash_aset(parent->val, rkey, rstr);
|
55
|
-
}
|
56
|
-
if (Yes == pi->options.trace) {
|
57
|
-
oj_trace_parse_call("set_string", pi, __FILE__, __LINE__, rstr);
|
58
|
-
}
|
26
|
+
volatile VALUE rstr = oj_cstr_to_value(str, len, (size_t)pi->options.cache_str);
|
27
|
+
volatile VALUE rkey = oj_calc_hash_key(pi, kval);
|
28
|
+
|
29
|
+
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
30
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
31
|
+
|
32
|
+
if (Qnil != clas) {
|
33
|
+
rstr = rb_funcall(clas, oj_json_create_id, 1, rstr);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
if (rb_cHash != rb_obj_class(parent->val)) {
|
37
|
+
// The rb_hash_set would still work but the unit tests for the
|
38
|
+
// json gem require the less efficient []= method be called to set
|
39
|
+
// values. Even using the store method to set the values will fail
|
40
|
+
// the unit tests.
|
41
|
+
rb_funcall(parent->val, rb_intern("[]="), 2, rkey, rstr);
|
42
|
+
} else {
|
43
|
+
rb_hash_aset(parent->val, rkey, rstr);
|
44
|
+
}
|
45
|
+
TRACE_PARSE_CALL(pi->options.trace, "set_string", pi, rstr);
|
59
46
|
}
|
60
47
|
}
|
61
48
|
|
62
|
-
static VALUE
|
63
|
-
|
64
|
-
volatile VALUE h;
|
49
|
+
static VALUE start_hash(ParseInfo pi) {
|
50
|
+
volatile VALUE h;
|
65
51
|
|
66
52
|
if (Qnil != pi->options.hash_class) {
|
67
|
-
|
53
|
+
h = rb_class_new_instance(0, NULL, pi->options.hash_class);
|
68
54
|
} else {
|
69
|
-
|
70
|
-
}
|
71
|
-
if (Yes == pi->options.trace) {
|
72
|
-
oj_trace_parse_in("start_hash", pi, __FILE__, __LINE__);
|
55
|
+
h = rb_hash_new();
|
73
56
|
}
|
57
|
+
TRACE_PARSE_IN(pi->options.trace, "start_hash", pi);
|
74
58
|
return h;
|
75
59
|
}
|
76
60
|
|
77
|
-
static void
|
78
|
-
|
79
|
-
Val parent = stack_peek(&pi->stack);
|
61
|
+
static void end_hash(struct _parseInfo *pi) {
|
62
|
+
Val parent = stack_peek(&pi->stack);
|
80
63
|
|
81
64
|
if (0 != parent->classname) {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
}
|
97
|
-
|
98
|
-
oj_trace_parse_hash_end(pi, __FILE__, __LINE__);
|
99
|
-
}
|
65
|
+
volatile VALUE clas;
|
66
|
+
|
67
|
+
clas = oj_name2class(pi, parent->classname, parent->clen, 0, rb_eArgError);
|
68
|
+
if (Qundef != clas) { // else an error
|
69
|
+
ID creatable = rb_intern("json_creatable?");
|
70
|
+
|
71
|
+
if (!rb_respond_to(clas, creatable) || Qtrue == rb_funcall(clas, creatable, 0)) {
|
72
|
+
parent->val = rb_funcall(clas, oj_json_create_id, 1, parent->val);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
if (0 != parent->classname) {
|
76
|
+
OJ_R_FREE((char *)parent->classname);
|
77
|
+
parent->classname = 0;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
TRACE_PARSE_HASH_END(pi->options.trace, pi);
|
100
81
|
}
|
101
82
|
|
102
|
-
static
|
103
|
-
|
104
|
-
volatile VALUE rkey = parent->key_val;
|
105
|
-
|
106
|
-
if (Qundef == rkey) {
|
107
|
-
rkey = rb_str_new(parent->key, parent->klen);
|
108
|
-
}
|
109
|
-
rkey = oj_encode(rkey);
|
110
|
-
if (Yes == pi->options.sym_key) {
|
111
|
-
rkey = rb_str_intern(rkey);
|
112
|
-
}
|
113
|
-
return rkey;
|
114
|
-
}
|
83
|
+
static void add_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) {
|
84
|
+
volatile VALUE rstr = oj_cstr_to_value(str, len, (size_t)pi->options.cache_str);
|
115
85
|
|
116
|
-
static void
|
117
|
-
add_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) {
|
118
|
-
volatile VALUE rstr = rb_str_new(str, len);
|
119
|
-
|
120
|
-
rstr = oj_encode(rstr);
|
121
86
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
122
|
-
|
87
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
123
88
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
89
|
+
if (Qnil != clas) {
|
90
|
+
pi->stack.head->val = rb_funcall(clas, oj_json_create_id, 1, rstr);
|
91
|
+
return;
|
92
|
+
}
|
128
93
|
}
|
129
94
|
pi->stack.head->val = rstr;
|
130
|
-
|
131
|
-
oj_trace_parse_call("add_string", pi, __FILE__, __LINE__, rstr);
|
132
|
-
}
|
95
|
+
TRACE_PARSE_CALL(pi->options.trace, "add_string", pi, rstr);
|
133
96
|
}
|
134
97
|
|
135
|
-
static void
|
136
|
-
add_num(ParseInfo pi, NumInfo ni) {
|
98
|
+
static void add_num(ParseInfo pi, NumInfo ni) {
|
137
99
|
pi->stack.head->val = oj_num_as_value(ni);
|
138
|
-
|
139
|
-
oj_trace_parse_call("add_number", pi, __FILE__, __LINE__, pi->stack.head->val);
|
140
|
-
}
|
100
|
+
TRACE_PARSE_CALL(pi->options.trace, "add_number", pi, pi->stack.head->val);
|
141
101
|
}
|
142
102
|
|
143
|
-
static void
|
144
|
-
|
145
|
-
volatile VALUE rval = oj_num_as_value(ni);
|
103
|
+
static void hash_set_num(struct _parseInfo *pi, Val parent, NumInfo ni) {
|
104
|
+
volatile VALUE rval = oj_num_as_value(ni);
|
146
105
|
|
147
|
-
if (
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
106
|
+
if (rb_cHash != rb_obj_class(parent->val)) {
|
107
|
+
// The rb_hash_set would still work but the unit tests for the
|
108
|
+
// json gem require the less efficient []= method be called to set
|
109
|
+
// values. Even using the store method to set the values will fail
|
110
|
+
// the unit tests.
|
111
|
+
rb_funcall(stack_peek(&pi->stack)->val, rb_intern("[]="), 2, oj_calc_hash_key(pi, parent), rval);
|
153
112
|
} else {
|
154
|
-
|
155
|
-
}
|
156
|
-
if (Yes == pi->options.trace) {
|
157
|
-
oj_trace_parse_call("set_number", pi, __FILE__, __LINE__, rval);
|
113
|
+
rb_hash_aset(stack_peek(&pi->stack)->val, oj_calc_hash_key(pi, parent), rval);
|
158
114
|
}
|
115
|
+
TRACE_PARSE_CALL(pi->options.trace, "set_number", pi, rval);
|
159
116
|
}
|
160
117
|
|
161
|
-
static void
|
162
|
-
hash_set_value(ParseInfo pi, Val parent, VALUE value) {
|
118
|
+
static void hash_set_value(ParseInfo pi, Val parent, VALUE value) {
|
163
119
|
if (rb_cHash != rb_obj_class(parent->val)) {
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
120
|
+
// The rb_hash_set would still work but the unit tests for the
|
121
|
+
// json gem require the less efficient []= method be called to set
|
122
|
+
// values. Even using the store method to set the values will fail
|
123
|
+
// the unit tests.
|
124
|
+
rb_funcall(stack_peek(&pi->stack)->val, rb_intern("[]="), 2, oj_calc_hash_key(pi, parent), value);
|
169
125
|
} else {
|
170
|
-
|
171
|
-
}
|
172
|
-
if (Yes == pi->options.trace) {
|
173
|
-
oj_trace_parse_call("set_value", pi, __FILE__, __LINE__, value);
|
126
|
+
rb_hash_aset(stack_peek(&pi->stack)->val, oj_calc_hash_key(pi, parent), value);
|
174
127
|
}
|
128
|
+
TRACE_PARSE_CALL(pi->options.trace, "set_value", pi, value);
|
175
129
|
}
|
176
130
|
|
177
|
-
static VALUE
|
178
|
-
start_array(ParseInfo pi) {
|
131
|
+
static VALUE start_array(ParseInfo pi) {
|
179
132
|
if (Qnil != pi->options.array_class) {
|
180
|
-
|
181
|
-
}
|
182
|
-
if (Yes == pi->options.trace) {
|
183
|
-
oj_trace_parse_in("start_array", pi, __FILE__, __LINE__);
|
133
|
+
return rb_class_new_instance(0, NULL, pi->options.array_class);
|
184
134
|
}
|
135
|
+
TRACE_PARSE_IN(pi->options.trace, "start_array", pi);
|
185
136
|
return rb_ary_new();
|
186
137
|
}
|
187
138
|
|
188
|
-
static void
|
189
|
-
|
190
|
-
|
191
|
-
volatile VALUE rval = oj_num_as_value(ni);
|
139
|
+
static void array_append_num(ParseInfo pi, NumInfo ni) {
|
140
|
+
Val parent = stack_peek(&pi->stack);
|
141
|
+
volatile VALUE rval = oj_num_as_value(ni);
|
192
142
|
|
193
143
|
if (!oj_use_array_alt && rb_cArray != rb_obj_class(parent->val)) {
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
144
|
+
// The rb_ary_push would still work but the unit tests for the json
|
145
|
+
// gem require the less efficient << method be called to push the
|
146
|
+
// values.
|
147
|
+
rb_funcall(parent->val, rb_intern("<<"), 1, rval);
|
198
148
|
} else {
|
199
|
-
|
200
|
-
}
|
201
|
-
if (Yes == pi->options.trace) {
|
202
|
-
oj_trace_parse_call("append_number", pi, __FILE__, __LINE__, rval);
|
149
|
+
rb_ary_push(parent->val, rval);
|
203
150
|
}
|
151
|
+
TRACE_PARSE_CALL(pi->options.trace, "append_number", pi, rval);
|
204
152
|
}
|
205
153
|
|
206
|
-
static void
|
207
|
-
|
208
|
-
volatile VALUE rstr = rb_str_new(str, len);
|
154
|
+
static void array_append_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) {
|
155
|
+
volatile VALUE rstr = oj_cstr_to_value(str, len, (size_t)pi->options.cache_str);
|
209
156
|
|
210
|
-
rstr = oj_encode(rstr);
|
211
157
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
212
|
-
|
158
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
213
159
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
160
|
+
if (Qnil != clas) {
|
161
|
+
rb_ary_push(stack_peek(&pi->stack)->val, rb_funcall(clas, oj_json_create_id, 1, rstr));
|
162
|
+
return;
|
163
|
+
}
|
218
164
|
}
|
219
165
|
rb_ary_push(stack_peek(&pi->stack)->val, rstr);
|
220
|
-
|
221
|
-
oj_trace_parse_call("append_string", pi, __FILE__, __LINE__, rstr);
|
222
|
-
}
|
166
|
+
TRACE_PARSE_CALL(pi->options.trace, "append_string", pi, rstr);
|
223
167
|
}
|
224
168
|
|
225
|
-
void
|
226
|
-
oj_set_compat_callbacks(ParseInfo pi) {
|
169
|
+
void oj_set_compat_callbacks(ParseInfo pi) {
|
227
170
|
oj_set_strict_callbacks(pi);
|
228
|
-
pi->start_hash
|
229
|
-
pi->end_hash
|
230
|
-
pi->hash_set_cstr
|
231
|
-
pi->hash_set_num
|
232
|
-
pi->hash_set_value
|
233
|
-
pi->add_num
|
234
|
-
pi->add_cstr
|
171
|
+
pi->start_hash = start_hash;
|
172
|
+
pi->end_hash = end_hash;
|
173
|
+
pi->hash_set_cstr = hash_set_cstr;
|
174
|
+
pi->hash_set_num = hash_set_num;
|
175
|
+
pi->hash_set_value = hash_set_value;
|
176
|
+
pi->add_num = add_num;
|
177
|
+
pi->add_cstr = add_cstr;
|
235
178
|
pi->array_append_cstr = array_append_cstr;
|
236
|
-
pi->start_array
|
237
|
-
pi->array_append_num
|
179
|
+
pi->start_array = start_array;
|
180
|
+
pi->array_append_num = array_append_num;
|
238
181
|
}
|
239
182
|
|
240
183
|
VALUE
|
241
184
|
oj_compat_parse(int argc, VALUE *argv, VALUE self) {
|
242
|
-
struct _parseInfo
|
185
|
+
struct _parseInfo pi;
|
243
186
|
|
244
187
|
parse_info_init(&pi);
|
245
|
-
pi.options
|
246
|
-
pi.handler
|
247
|
-
pi.err_class
|
248
|
-
pi.max_depth
|
249
|
-
pi.options.allow_nan
|
250
|
-
pi.options.nilnil
|
188
|
+
pi.options = oj_default_options;
|
189
|
+
pi.handler = Qnil;
|
190
|
+
pi.err_class = Qnil;
|
191
|
+
pi.max_depth = 0;
|
192
|
+
pi.options.allow_nan = Yes;
|
193
|
+
pi.options.nilnil = Yes;
|
251
194
|
pi.options.empty_string = No;
|
252
195
|
oj_set_compat_callbacks(&pi);
|
253
196
|
|
254
197
|
if (T_STRING == rb_type(*argv)) {
|
255
|
-
|
198
|
+
return oj_pi_parse(argc, argv, &pi, 0, 0, false);
|
256
199
|
} else {
|
257
|
-
|
200
|
+
return oj_pi_sparse(argc, argv, &pi, 0);
|
258
201
|
}
|
259
202
|
}
|
260
203
|
|
261
204
|
VALUE
|
262
205
|
oj_compat_load(int argc, VALUE *argv, VALUE self) {
|
263
|
-
struct _parseInfo
|
206
|
+
struct _parseInfo pi;
|
264
207
|
|
265
208
|
parse_info_init(&pi);
|
266
|
-
pi.options
|
267
|
-
pi.handler
|
268
|
-
pi.err_class
|
269
|
-
pi.max_depth
|
270
|
-
pi.options.allow_nan
|
271
|
-
pi.options.nilnil
|
209
|
+
pi.options = oj_default_options;
|
210
|
+
pi.handler = Qnil;
|
211
|
+
pi.err_class = Qnil;
|
212
|
+
pi.max_depth = 0;
|
213
|
+
pi.options.allow_nan = Yes;
|
214
|
+
pi.options.nilnil = Yes;
|
272
215
|
pi.options.empty_string = Yes;
|
273
216
|
oj_set_compat_callbacks(&pi);
|
274
217
|
|
275
218
|
if (T_STRING == rb_type(*argv)) {
|
276
|
-
|
219
|
+
return oj_pi_parse(argc, argv, &pi, 0, 0, false);
|
277
220
|
} else {
|
278
|
-
|
221
|
+
return oj_pi_sparse(argc, argv, &pi, 0);
|
279
222
|
}
|
280
223
|
}
|
281
224
|
|
282
225
|
VALUE
|
283
226
|
oj_compat_parse_cstr(int argc, VALUE *argv, char *json, size_t len) {
|
284
|
-
struct _parseInfo
|
227
|
+
struct _parseInfo pi;
|
285
228
|
|
286
229
|
parse_info_init(&pi);
|
287
|
-
pi.options
|
288
|
-
pi.handler
|
289
|
-
pi.err_class
|
290
|
-
pi.max_depth
|
230
|
+
pi.options = oj_default_options;
|
231
|
+
pi.handler = Qnil;
|
232
|
+
pi.err_class = Qnil;
|
233
|
+
pi.max_depth = 0;
|
291
234
|
pi.options.allow_nan = Yes;
|
292
|
-
pi.options.nilnil
|
235
|
+
pi.options.nilnil = Yes;
|
293
236
|
oj_set_compat_callbacks(&pi);
|
294
237
|
|
295
238
|
return oj_pi_parse(argc, argv, &pi, json, len, false);
|