oj 3.9.1 → 3.16.11
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 +1452 -0
- data/README.md +21 -6
- data/RELEASE_NOTES.md +61 -0
- data/ext/oj/buf.h +50 -68
- 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 +9 -36
- data/ext/oj/circarray.c +38 -42
- data/ext/oj/circarray.h +12 -13
- data/ext/oj/code.c +158 -179
- data/ext/oj/code.h +20 -22
- data/ext/oj/compat.c +145 -205
- data/ext/oj/custom.c +740 -880
- data/ext/oj/debug.c +126 -0
- data/ext/oj/dump.c +1145 -844
- data/ext/oj/dump.h +71 -57
- data/ext/oj/dump_compat.c +575 -655
- data/ext/oj/dump_leaf.c +96 -186
- data/ext/oj/dump_object.c +533 -660
- data/ext/oj/dump_strict.c +306 -340
- data/ext/oj/encode.h +4 -33
- data/ext/oj/encoder.c +43 -0
- data/ext/oj/err.c +28 -28
- data/ext/oj/err.h +39 -42
- data/ext/oj/extconf.rb +28 -7
- data/ext/oj/fast.c +1052 -1113
- 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 +471 -430
- data/ext/oj/object.c +532 -580
- data/ext/oj/odd.c +156 -142
- data/ext/oj/odd.h +25 -26
- data/ext/oj/oj.c +1346 -961
- data/ext/oj/oj.h +307 -290
- data/ext/oj/parse.c +954 -858
- data/ext/oj/parse.h +74 -72
- data/ext/oj/parser.c +1600 -0
- data/ext/oj/parser.h +103 -0
- data/ext/oj/rails.c +819 -836
- data/ext/oj/rails.h +8 -11
- data/ext/oj/reader.c +136 -147
- data/ext/oj/reader.h +69 -83
- data/ext/oj/resolve.c +41 -63
- data/ext/oj/resolve.h +4 -6
- data/ext/oj/rxclass.c +69 -72
- data/ext/oj/rxclass.h +12 -13
- data/ext/oj/saj.c +440 -485
- data/ext/oj/saj2.c +584 -0
- data/ext/oj/saj2.h +23 -0
- data/ext/oj/scp.c +79 -118
- data/ext/oj/simd.h +10 -0
- data/ext/oj/sparse.c +739 -709
- data/ext/oj/stream_writer.c +141 -175
- data/ext/oj/strict.c +103 -128
- data/ext/oj/string_writer.c +244 -261
- data/ext/oj/trace.c +34 -41
- data/ext/oj/trace.h +42 -15
- data/ext/oj/usual.c +1218 -0
- data/ext/oj/usual.h +69 -0
- data/ext/oj/util.c +107 -107
- data/ext/oj/util.h +4 -3
- data/ext/oj/val_stack.c +61 -78
- data/ext/oj/val_stack.h +80 -114
- data/ext/oj/validate.c +46 -0
- data/ext/oj/wab.c +316 -361
- 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 +54 -20
- 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 -8
- data/pages/Compatibility.md +1 -1
- data/pages/Encoding.md +1 -1
- data/pages/InstallOptions.md +20 -0
- data/pages/JsonGem.md +15 -0
- data/pages/Modes.md +9 -3
- data/pages/Options.md +62 -12
- data/pages/Parser.md +309 -0
- data/pages/Rails.md +73 -22
- metadata +68 -192
- data/ext/oj/hash.c +0 -163
- data/ext/oj/hash.h +0 -46
- data/ext/oj/hash_test.c +0 -512
- data/test/_test_active.rb +0 -76
- data/test/_test_active_mimic.rb +0 -96
- data/test/_test_mimic_rails.rb +0 -126
- data/test/activerecord/result_test.rb +0 -27
- 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/decoding_test.rb +0 -125
- data/test/activesupport5/encoding_test.rb +0 -485
- data/test/activesupport5/encoding_test_cases.rb +0 -90
- data/test/activesupport5/test_helper.rb +0 -50
- data/test/activesupport5/time_zone_test_helpers.rb +0 -24
- data/test/bar.rb +0 -25
- data/test/files.rb +0 -29
- data/test/foo.rb +0 -21
- data/test/helper.rb +0 -26
- data/test/isolated/shared.rb +0 -308
- data/test/isolated/test_mimic_after.rb +0 -13
- data/test/isolated/test_mimic_alone.rb +0 -12
- data/test/isolated/test_mimic_as_json.rb +0 -45
- data/test/isolated/test_mimic_before.rb +0 -13
- data/test/isolated/test_mimic_define.rb +0 -28
- data/test/isolated/test_mimic_rails_after.rb +0 -22
- data/test/isolated/test_mimic_rails_before.rb +0 -21
- data/test/isolated/test_mimic_redefine.rb +0 -15
- data/test/json_gem/json_addition_test.rb +0 -216
- data/test/json_gem/json_common_interface_test.rb +0 -148
- data/test/json_gem/json_encoding_test.rb +0 -107
- data/test/json_gem/json_ext_parser_test.rb +0 -20
- data/test/json_gem/json_fixtures_test.rb +0 -35
- data/test/json_gem/json_generator_test.rb +0 -383
- data/test/json_gem/json_generic_object_test.rb +0 -90
- data/test/json_gem/json_parser_test.rb +0 -470
- data/test/json_gem/json_string_matching_test.rb +0 -42
- data/test/json_gem/test_helper.rb +0 -18
- data/test/perf.rb +0 -107
- data/test/perf_compat.rb +0 -130
- data/test/perf_fast.rb +0 -164
- data/test/perf_file.rb +0 -64
- data/test/perf_object.rb +0 -138
- data/test/perf_saj.rb +0 -109
- data/test/perf_scp.rb +0 -151
- data/test/perf_simple.rb +0 -287
- data/test/perf_strict.rb +0 -145
- data/test/perf_wab.rb +0 -131
- data/test/sample/change.rb +0 -14
- data/test/sample/dir.rb +0 -19
- data/test/sample/doc.rb +0 -36
- data/test/sample/file.rb +0 -48
- data/test/sample/group.rb +0 -16
- data/test/sample/hasprops.rb +0 -16
- data/test/sample/layer.rb +0 -12
- data/test/sample/line.rb +0 -20
- data/test/sample/oval.rb +0 -10
- data/test/sample/rect.rb +0 -10
- data/test/sample/shape.rb +0 -35
- data/test/sample/text.rb +0 -20
- data/test/sample.rb +0 -54
- data/test/sample_json.rb +0 -37
- data/test/test_compat.rb +0 -509
- data/test/test_custom.rb +0 -503
- data/test/test_debian.rb +0 -53
- data/test/test_fast.rb +0 -470
- data/test/test_file.rb +0 -239
- data/test/test_gc.rb +0 -49
- data/test/test_hash.rb +0 -29
- data/test/test_integer_range.rb +0 -73
- data/test/test_null.rb +0 -376
- data/test/test_object.rb +0 -1018
- data/test/test_saj.rb +0 -186
- data/test/test_scp.rb +0 -433
- data/test/test_strict.rb +0 -410
- data/test/test_various.rb +0 -741
- data/test/test_wab.rb +0 -307
- data/test/test_writer.rb +0 -380
- data/test/tests.rb +0 -24
- data/test/tests_mimic.rb +0 -14
- data/test/tests_mimic_addition.rb +0 -7
- data/test/zoo.rb +0 -13
data/ext/oj/compat.c
CHANGED
@@ -1,298 +1,238 @@
|
|
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 "mem.h"
|
10
|
+
#include "oj.h"
|
10
11
|
#include "parse.h"
|
11
12
|
#include "resolve.h"
|
12
|
-
#include "hash.h"
|
13
|
-
#include "encode.h"
|
14
13
|
#include "trace.h"
|
15
14
|
|
16
|
-
static void
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
*pi->options.create_id == *key &&
|
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;
|
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;
|
32
25
|
} else {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
// values. Even using the store method to set the values will fail
|
54
|
-
// the unit tests.
|
55
|
-
rb_funcall(parent->val, rb_intern("[]="), 2, rkey, rstr);
|
56
|
-
} else {
|
57
|
-
rb_hash_aset(parent->val, rkey, rstr);
|
58
|
-
}
|
59
|
-
if (Yes == pi->options.trace) {
|
60
|
-
oj_trace_parse_call("set_string", pi, __FILE__, __LINE__, rstr);
|
61
|
-
}
|
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);
|
62
46
|
}
|
63
47
|
}
|
64
48
|
|
65
|
-
static VALUE
|
66
|
-
|
67
|
-
|
68
|
-
|
49
|
+
static VALUE start_hash(ParseInfo pi) {
|
50
|
+
volatile VALUE h;
|
51
|
+
|
69
52
|
if (Qnil != pi->options.hash_class) {
|
70
|
-
|
53
|
+
h = rb_class_new_instance(0, NULL, pi->options.hash_class);
|
71
54
|
} else {
|
72
|
-
|
73
|
-
}
|
74
|
-
if (Yes == pi->options.trace) {
|
75
|
-
oj_trace_parse_in("start_hash", pi, __FILE__, __LINE__);
|
55
|
+
h = rb_hash_new();
|
76
56
|
}
|
57
|
+
TRACE_PARSE_IN(pi->options.trace, "start_hash", pi);
|
77
58
|
return h;
|
78
59
|
}
|
79
60
|
|
80
|
-
static void
|
81
|
-
|
82
|
-
Val parent = stack_peek(&pi->stack);
|
61
|
+
static void end_hash(struct _parseInfo *pi) {
|
62
|
+
Val parent = stack_peek(&pi->stack);
|
83
63
|
|
84
64
|
if (0 != parent->classname) {
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
oj_trace_parse_hash_end(pi, __FILE__, __LINE__);
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
static VALUE
|
106
|
-
calc_hash_key(ParseInfo pi, Val parent) {
|
107
|
-
volatile VALUE rkey = parent->key_val;
|
108
|
-
|
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;
|
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);
|
117
81
|
}
|
118
82
|
|
119
|
-
static void
|
120
|
-
|
121
|
-
volatile VALUE rstr = rb_str_new(str, len);
|
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);
|
122
85
|
|
123
|
-
rstr = oj_encode(rstr);
|
124
86
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
125
|
-
|
87
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
126
88
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
89
|
+
if (Qnil != clas) {
|
90
|
+
pi->stack.head->val = rb_funcall(clas, oj_json_create_id, 1, rstr);
|
91
|
+
return;
|
92
|
+
}
|
131
93
|
}
|
132
94
|
pi->stack.head->val = rstr;
|
133
|
-
|
134
|
-
oj_trace_parse_call("add_string", pi, __FILE__, __LINE__, rstr);
|
135
|
-
}
|
95
|
+
TRACE_PARSE_CALL(pi->options.trace, "add_string", pi, rstr);
|
136
96
|
}
|
137
97
|
|
138
|
-
static void
|
139
|
-
add_num(ParseInfo pi, NumInfo ni) {
|
98
|
+
static void add_num(ParseInfo pi, NumInfo ni) {
|
140
99
|
pi->stack.head->val = oj_num_as_value(ni);
|
141
|
-
|
142
|
-
oj_trace_parse_call("add_number", pi, __FILE__, __LINE__, pi->stack.head->val);
|
143
|
-
}
|
100
|
+
TRACE_PARSE_CALL(pi->options.trace, "add_number", pi, pi->stack.head->val);
|
144
101
|
}
|
145
102
|
|
146
|
-
static void
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
rb_funcall(stack_peek(&pi->stack)->val, rb_intern("[]="), 2, calc_hash_key(pi, parent), rval);
|
103
|
+
static void hash_set_num(struct _parseInfo *pi, Val parent, NumInfo ni) {
|
104
|
+
volatile VALUE rval = oj_num_as_value(ni);
|
105
|
+
|
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);
|
156
112
|
} else {
|
157
|
-
|
158
|
-
}
|
159
|
-
if (Yes == pi->options.trace) {
|
160
|
-
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);
|
161
114
|
}
|
115
|
+
TRACE_PARSE_CALL(pi->options.trace, "set_number", pi, rval);
|
162
116
|
}
|
163
117
|
|
164
|
-
static void
|
165
|
-
hash_set_value(ParseInfo pi, Val parent, VALUE value) {
|
118
|
+
static void hash_set_value(ParseInfo pi, Val parent, VALUE value) {
|
166
119
|
if (rb_cHash != rb_obj_class(parent->val)) {
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
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);
|
172
125
|
} else {
|
173
|
-
|
174
|
-
}
|
175
|
-
if (Yes == pi->options.trace) {
|
176
|
-
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);
|
177
127
|
}
|
128
|
+
TRACE_PARSE_CALL(pi->options.trace, "set_value", pi, value);
|
178
129
|
}
|
179
130
|
|
180
|
-
static VALUE
|
181
|
-
start_array(ParseInfo pi) {
|
131
|
+
static VALUE start_array(ParseInfo pi) {
|
182
132
|
if (Qnil != pi->options.array_class) {
|
183
|
-
|
184
|
-
}
|
185
|
-
if (Yes == pi->options.trace) {
|
186
|
-
oj_trace_parse_in("start_array", pi, __FILE__, __LINE__);
|
133
|
+
return rb_class_new_instance(0, NULL, pi->options.array_class);
|
187
134
|
}
|
135
|
+
TRACE_PARSE_IN(pi->options.trace, "start_array", pi);
|
188
136
|
return rb_ary_new();
|
189
137
|
}
|
190
138
|
|
191
|
-
static void
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
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);
|
142
|
+
|
196
143
|
if (!oj_use_array_alt && rb_cArray != rb_obj_class(parent->val)) {
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
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);
|
201
148
|
} else {
|
202
|
-
|
203
|
-
}
|
204
|
-
if (Yes == pi->options.trace) {
|
205
|
-
oj_trace_parse_call("append_number", pi, __FILE__, __LINE__, rval);
|
149
|
+
rb_ary_push(parent->val, rval);
|
206
150
|
}
|
151
|
+
TRACE_PARSE_CALL(pi->options.trace, "append_number", pi, rval);
|
207
152
|
}
|
208
153
|
|
209
|
-
static void
|
210
|
-
|
211
|
-
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);
|
212
156
|
|
213
|
-
rstr = oj_encode(rstr);
|
214
157
|
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
215
|
-
|
158
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
216
159
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
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
|
+
}
|
221
164
|
}
|
222
165
|
rb_ary_push(stack_peek(&pi->stack)->val, rstr);
|
223
|
-
|
224
|
-
oj_trace_parse_call("append_string", pi, __FILE__, __LINE__, rstr);
|
225
|
-
}
|
166
|
+
TRACE_PARSE_CALL(pi->options.trace, "append_string", pi, rstr);
|
226
167
|
}
|
227
168
|
|
228
|
-
void
|
229
|
-
oj_set_compat_callbacks(ParseInfo pi) {
|
169
|
+
void oj_set_compat_callbacks(ParseInfo pi) {
|
230
170
|
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
|
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;
|
238
178
|
pi->array_append_cstr = array_append_cstr;
|
239
|
-
pi->start_array
|
240
|
-
pi->array_append_num
|
179
|
+
pi->start_array = start_array;
|
180
|
+
pi->array_append_num = array_append_num;
|
241
181
|
}
|
242
182
|
|
243
183
|
VALUE
|
244
184
|
oj_compat_parse(int argc, VALUE *argv, VALUE self) {
|
245
|
-
struct _parseInfo
|
185
|
+
struct _parseInfo pi;
|
246
186
|
|
247
187
|
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
|
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;
|
254
194
|
pi.options.empty_string = No;
|
255
195
|
oj_set_compat_callbacks(&pi);
|
256
196
|
|
257
197
|
if (T_STRING == rb_type(*argv)) {
|
258
|
-
|
198
|
+
return oj_pi_parse(argc, argv, &pi, 0, 0, false);
|
259
199
|
} else {
|
260
|
-
|
200
|
+
return oj_pi_sparse(argc, argv, &pi, 0);
|
261
201
|
}
|
262
202
|
}
|
263
203
|
|
264
204
|
VALUE
|
265
205
|
oj_compat_load(int argc, VALUE *argv, VALUE self) {
|
266
|
-
struct _parseInfo
|
206
|
+
struct _parseInfo pi;
|
267
207
|
|
268
208
|
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
|
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;
|
275
215
|
pi.options.empty_string = Yes;
|
276
216
|
oj_set_compat_callbacks(&pi);
|
277
|
-
|
217
|
+
|
278
218
|
if (T_STRING == rb_type(*argv)) {
|
279
|
-
|
219
|
+
return oj_pi_parse(argc, argv, &pi, 0, 0, false);
|
280
220
|
} else {
|
281
|
-
|
221
|
+
return oj_pi_sparse(argc, argv, &pi, 0);
|
282
222
|
}
|
283
223
|
}
|
284
224
|
|
285
225
|
VALUE
|
286
226
|
oj_compat_parse_cstr(int argc, VALUE *argv, char *json, size_t len) {
|
287
|
-
struct _parseInfo
|
227
|
+
struct _parseInfo pi;
|
288
228
|
|
289
229
|
parse_info_init(&pi);
|
290
|
-
pi.options
|
291
|
-
pi.handler
|
292
|
-
pi.err_class
|
293
|
-
pi.max_depth
|
230
|
+
pi.options = oj_default_options;
|
231
|
+
pi.handler = Qnil;
|
232
|
+
pi.err_class = Qnil;
|
233
|
+
pi.max_depth = 0;
|
294
234
|
pi.options.allow_nan = Yes;
|
295
|
-
pi.options.nilnil
|
235
|
+
pi.options.nilnil = Yes;
|
296
236
|
oj_set_compat_callbacks(&pi);
|
297
237
|
|
298
238
|
return oj_pi_parse(argc, argv, &pi, json, len, false);
|