oj 2.18.5 → 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 +5 -5
- data/CHANGELOG.md +1452 -0
- data/README.md +53 -221
- data/RELEASE_NOTES.md +61 -0
- data/ext/oj/buf.h +54 -72
- data/ext/oj/cache.c +329 -0
- data/ext/oj/cache.h +22 -0
- data/ext/oj/cache8.c +61 -63
- data/ext/oj/cache8.h +12 -39
- data/ext/oj/circarray.c +38 -67
- data/ext/oj/circarray.h +16 -42
- data/ext/oj/code.c +214 -0
- data/ext/oj/code.h +40 -0
- data/ext/oj/compat.c +194 -110
- data/ext/oj/custom.c +1074 -0
- data/ext/oj/debug.c +126 -0
- data/ext/oj/dump.c +1276 -2494
- data/ext/oj/dump.h +110 -0
- data/ext/oj/dump_compat.c +897 -0
- data/ext/oj/dump_leaf.c +162 -0
- data/ext/oj/dump_object.c +710 -0
- data/ext/oj/dump_strict.c +399 -0
- data/ext/oj/encode.h +7 -42
- data/ext/oj/encoder.c +43 -0
- data/ext/oj/err.c +28 -53
- data/ext/oj/err.h +49 -46
- data/ext/oj/extconf.rb +33 -32
- data/ext/oj/fast.c +1082 -1098
- 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 +919 -0
- data/ext/oj/object.c +545 -625
- data/ext/oj/odd.c +158 -168
- data/ext/oj/odd.h +32 -58
- data/ext/oj/oj.c +1727 -2080
- data/ext/oj/oj.h +334 -259
- data/ext/oj/parse.c +974 -753
- data/ext/oj/parse.h +97 -90
- data/ext/oj/parser.c +1600 -0
- data/ext/oj/parser.h +103 -0
- data/ext/oj/rails.c +1478 -0
- data/ext/oj/rails.h +18 -0
- data/ext/oj/reader.c +136 -163
- data/ext/oj/reader.h +76 -112
- data/ext/oj/resolve.c +45 -94
- data/ext/oj/resolve.h +7 -34
- data/ext/oj/rxclass.c +144 -0
- data/ext/oj/rxclass.h +26 -0
- data/ext/oj/saj.c +445 -511
- data/ext/oj/saj2.c +584 -0
- data/ext/oj/saj2.h +23 -0
- data/ext/oj/scp.c +82 -143
- data/ext/oj/simd.h +10 -0
- data/ext/oj/sparse.c +749 -644
- data/ext/oj/stream_writer.c +329 -0
- data/ext/oj/strict.c +114 -112
- data/ext/oj/string_writer.c +517 -0
- data/ext/oj/trace.c +72 -0
- data/ext/oj/trace.h +55 -0
- data/ext/oj/usual.c +1218 -0
- data/ext/oj/usual.h +69 -0
- data/ext/oj/util.c +136 -0
- data/ext/oj/util.h +20 -0
- data/ext/oj/val_stack.c +75 -72
- data/ext/oj/val_stack.h +94 -127
- data/ext/oj/validate.c +46 -0
- data/ext/oj/wab.c +586 -0
- data/lib/oj/active_support_helper.rb +1 -3
- data/lib/oj/bag.rb +8 -1
- data/lib/oj/easy_hash.rb +21 -13
- data/lib/oj/error.rb +10 -12
- data/lib/oj/json.rb +188 -0
- data/lib/oj/mimic.rb +165 -26
- data/lib/oj/saj.rb +20 -6
- data/lib/oj/schandler.rb +5 -4
- data/lib/oj/state.rb +135 -0
- data/lib/oj/version.rb +2 -3
- data/lib/oj.rb +3 -31
- data/pages/Advanced.md +22 -0
- data/pages/Compatibility.md +25 -0
- data/pages/Custom.md +23 -0
- data/pages/Encoding.md +65 -0
- data/pages/InstallOptions.md +20 -0
- data/pages/JsonGem.md +94 -0
- data/pages/Modes.md +161 -0
- data/pages/Options.md +337 -0
- data/pages/Parser.md +309 -0
- data/pages/Rails.md +167 -0
- data/pages/Security.md +20 -0
- data/pages/WAB.md +13 -0
- metadata +126 -163
- 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/activesupport_datetime_test.rb +0 -23
- data/test/bug.rb +0 -51
- data/test/bug2.rb +0 -10
- data/test/bug3.rb +0 -46
- data/test/bug_fast.rb +0 -32
- data/test/bug_load.rb +0 -24
- data/test/crash.rb +0 -111
- data/test/curl/curl_oj.rb +0 -46
- data/test/curl/get_oj.rb +0 -24
- data/test/curl/just_curl.rb +0 -31
- data/test/curl/just_oj.rb +0 -51
- data/test/example.rb +0 -11
- data/test/files.rb +0 -29
- data/test/foo.rb +0 -24
- data/test/helper.rb +0 -27
- data/test/io.rb +0 -48
- data/test/isolated/shared.rb +0 -310
- 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_rails_datetime.rb +0 -27
- data/test/isolated/test_mimic_redefine.rb +0 -15
- data/test/mod.rb +0 -16
- data/test/perf.rb +0 -107
- data/test/perf_compat.rb +0 -128
- 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 -128
- data/test/rails.rb +0 -50
- data/test/russian.rb +0 -18
- 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 -55
- data/test/sample_json.rb +0 -37
- data/test/struct.rb +0 -29
- data/test/test_compat.rb +0 -398
- data/test/test_debian.rb +0 -53
- data/test/test_fast.rb +0 -458
- data/test/test_file.rb +0 -245
- data/test/test_gc.rb +0 -49
- data/test/test_hash.rb +0 -29
- data/test/test_object.rb +0 -745
- data/test/test_saj.rb +0 -186
- data/test/test_scp.rb +0 -396
- data/test/test_serializer.rb +0 -59
- data/test/test_strict.rb +0 -254
- data/test/test_various.rb +0 -1383
- data/test/test_writer.rb +0 -308
- data/test/write_timebars.rb +0 -31
data/ext/oj/compat.c
CHANGED
@@ -1,155 +1,239 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* Redistribution and use in source and binary forms, with or without
|
6
|
-
* modification, are permitted provided that the following conditions are met:
|
7
|
-
*
|
8
|
-
* - Redistributions of source code must retain the above copyright notice, this
|
9
|
-
* list of conditions and the following disclaimer.
|
10
|
-
*
|
11
|
-
* - Redistributions in binary form must reproduce the above copyright notice,
|
12
|
-
* this list of conditions and the following disclaimer in the documentation
|
13
|
-
* and/or other materials provided with the distribution.
|
14
|
-
*
|
15
|
-
* - Neither the name of Peter Ohler nor the names of its contributors may be
|
16
|
-
* used to endorse or promote products derived from this software without
|
17
|
-
* specific prior written permission.
|
18
|
-
*
|
19
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
23
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
25
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
26
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
27
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
*/
|
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.
|
30
3
|
|
31
4
|
#include <stdio.h>
|
32
5
|
|
33
|
-
#include "
|
6
|
+
#include "encode.h"
|
34
7
|
#include "err.h"
|
8
|
+
#include "intern.h"
|
9
|
+
#include "mem.h"
|
10
|
+
#include "oj.h"
|
35
11
|
#include "parse.h"
|
36
12
|
#include "resolve.h"
|
37
|
-
#include "
|
38
|
-
|
13
|
+
#include "trace.h"
|
14
|
+
|
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;
|
25
|
+
} else {
|
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);
|
46
|
+
}
|
47
|
+
}
|
39
48
|
|
40
|
-
static
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
volatile VALUE rkey = kval->key_val;
|
46
|
-
|
47
|
-
if (Qundef == rkey &&
|
48
|
-
0 != pi->options.create_id &&
|
49
|
-
*pi->options.create_id == *key &&
|
50
|
-
(int)pi->options.create_id_len == klen &&
|
51
|
-
0 == strncmp(pi->options.create_id, key, klen)) {
|
52
|
-
parent->classname = oj_strndup(str, len);
|
53
|
-
parent->clen = len;
|
49
|
+
static VALUE start_hash(ParseInfo pi) {
|
50
|
+
volatile VALUE h;
|
51
|
+
|
52
|
+
if (Qnil != pi->options.hash_class) {
|
53
|
+
h = rb_class_new_instance(0, NULL, pi->options.hash_class);
|
54
54
|
} else {
|
55
|
-
|
56
|
-
|
57
|
-
if (Qundef == rkey) {
|
58
|
-
rkey = rb_str_new(key, klen);
|
59
|
-
rstr = oj_encode(rstr);
|
60
|
-
rkey = oj_encode(rkey);
|
61
|
-
if (Yes == pi->options.sym_key) {
|
62
|
-
rkey = rb_str_intern(rkey);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
rb_hash_aset(parent->val, rkey, rstr);
|
55
|
+
h = rb_hash_new();
|
66
56
|
}
|
57
|
+
TRACE_PARSE_IN(pi->options.trace, "start_hash", pi);
|
58
|
+
return h;
|
67
59
|
}
|
68
60
|
|
69
|
-
static void
|
70
|
-
|
71
|
-
Val parent = stack_peek(&pi->stack);
|
61
|
+
static void end_hash(struct _parseInfo *pi) {
|
62
|
+
Val parent = stack_peek(&pi->stack);
|
72
63
|
|
73
64
|
if (0 != parent->classname) {
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
+
}
|
84
79
|
}
|
80
|
+
TRACE_PARSE_HASH_END(pi->options.trace, pi);
|
85
81
|
}
|
86
82
|
|
87
|
-
static
|
88
|
-
|
89
|
-
volatile VALUE rkey = parent->key_val;
|
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);
|
90
85
|
|
91
|
-
if (
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
86
|
+
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
87
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
88
|
+
|
89
|
+
if (Qnil != clas) {
|
90
|
+
pi->stack.head->val = rb_funcall(clas, oj_json_create_id, 1, rstr);
|
91
|
+
return;
|
92
|
+
}
|
97
93
|
}
|
98
|
-
|
94
|
+
pi->stack.head->val = rstr;
|
95
|
+
TRACE_PARSE_CALL(pi->options.trace, "add_string", pi, rstr);
|
99
96
|
}
|
100
97
|
|
101
|
-
static void
|
102
|
-
add_num(ParseInfo pi, NumInfo ni) {
|
98
|
+
static void add_num(ParseInfo pi, NumInfo ni) {
|
103
99
|
pi->stack.head->val = oj_num_as_value(ni);
|
100
|
+
TRACE_PARSE_CALL(pi->options.trace, "add_number", pi, pi->stack.head->val);
|
101
|
+
}
|
102
|
+
|
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);
|
112
|
+
} else {
|
113
|
+
rb_hash_aset(stack_peek(&pi->stack)->val, oj_calc_hash_key(pi, parent), rval);
|
114
|
+
}
|
115
|
+
TRACE_PARSE_CALL(pi->options.trace, "set_number", pi, rval);
|
116
|
+
}
|
117
|
+
|
118
|
+
static void hash_set_value(ParseInfo pi, Val parent, VALUE value) {
|
119
|
+
if (rb_cHash != rb_obj_class(parent->val)) {
|
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);
|
125
|
+
} else {
|
126
|
+
rb_hash_aset(stack_peek(&pi->stack)->val, oj_calc_hash_key(pi, parent), value);
|
127
|
+
}
|
128
|
+
TRACE_PARSE_CALL(pi->options.trace, "set_value", pi, value);
|
104
129
|
}
|
105
130
|
|
106
|
-
static
|
107
|
-
|
108
|
-
|
131
|
+
static VALUE start_array(ParseInfo pi) {
|
132
|
+
if (Qnil != pi->options.array_class) {
|
133
|
+
return rb_class_new_instance(0, NULL, pi->options.array_class);
|
134
|
+
}
|
135
|
+
TRACE_PARSE_IN(pi->options.trace, "start_array", pi);
|
136
|
+
return rb_ary_new();
|
109
137
|
}
|
110
138
|
|
111
|
-
static void
|
112
|
-
|
113
|
-
|
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
|
+
|
143
|
+
if (!oj_use_array_alt && rb_cArray != rb_obj_class(parent->val)) {
|
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);
|
148
|
+
} else {
|
149
|
+
rb_ary_push(parent->val, rval);
|
150
|
+
}
|
151
|
+
TRACE_PARSE_CALL(pi->options.trace, "append_number", pi, rval);
|
114
152
|
}
|
115
153
|
|
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);
|
156
|
+
|
157
|
+
if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
|
158
|
+
VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
|
159
|
+
|
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
|
+
}
|
164
|
+
}
|
165
|
+
rb_ary_push(stack_peek(&pi->stack)->val, rstr);
|
166
|
+
TRACE_PARSE_CALL(pi->options.trace, "append_string", pi, rstr);
|
167
|
+
}
|
116
168
|
|
117
|
-
void
|
118
|
-
oj_set_compat_callbacks(ParseInfo pi) {
|
169
|
+
void oj_set_compat_callbacks(ParseInfo pi) {
|
119
170
|
oj_set_strict_callbacks(pi);
|
120
|
-
pi->
|
121
|
-
pi->
|
122
|
-
pi->
|
123
|
-
pi->hash_set_num
|
124
|
-
pi->
|
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;
|
178
|
+
pi->array_append_cstr = array_append_cstr;
|
179
|
+
pi->start_array = start_array;
|
180
|
+
pi->array_append_num = array_append_num;
|
125
181
|
}
|
126
182
|
|
127
183
|
VALUE
|
128
184
|
oj_compat_parse(int argc, VALUE *argv, VALUE self) {
|
129
|
-
struct
|
185
|
+
struct _parseInfo pi;
|
186
|
+
|
187
|
+
parse_info_init(&pi);
|
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;
|
194
|
+
pi.options.empty_string = No;
|
195
|
+
oj_set_compat_callbacks(&pi);
|
130
196
|
|
131
|
-
|
132
|
-
|
133
|
-
|
197
|
+
if (T_STRING == rb_type(*argv)) {
|
198
|
+
return oj_pi_parse(argc, argv, &pi, 0, 0, false);
|
199
|
+
} else {
|
200
|
+
return oj_pi_sparse(argc, argv, &pi, 0);
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
VALUE
|
205
|
+
oj_compat_load(int argc, VALUE *argv, VALUE self) {
|
206
|
+
struct _parseInfo pi;
|
207
|
+
|
208
|
+
parse_info_init(&pi);
|
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;
|
215
|
+
pi.options.empty_string = Yes;
|
134
216
|
oj_set_compat_callbacks(&pi);
|
135
217
|
|
136
218
|
if (T_STRING == rb_type(*argv)) {
|
137
|
-
|
219
|
+
return oj_pi_parse(argc, argv, &pi, 0, 0, false);
|
138
220
|
} else {
|
139
|
-
|
221
|
+
return oj_pi_sparse(argc, argv, &pi, 0);
|
140
222
|
}
|
141
223
|
}
|
142
224
|
|
143
225
|
VALUE
|
144
226
|
oj_compat_parse_cstr(int argc, VALUE *argv, char *json, size_t len) {
|
145
|
-
struct
|
146
|
-
|
147
|
-
pi
|
148
|
-
pi.
|
149
|
-
pi.
|
150
|
-
|
151
|
-
pi.
|
152
|
-
pi.
|
227
|
+
struct _parseInfo pi;
|
228
|
+
|
229
|
+
parse_info_init(&pi);
|
230
|
+
pi.options = oj_default_options;
|
231
|
+
pi.handler = Qnil;
|
232
|
+
pi.err_class = Qnil;
|
233
|
+
pi.max_depth = 0;
|
234
|
+
pi.options.allow_nan = Yes;
|
235
|
+
pi.options.nilnil = Yes;
|
236
|
+
oj_set_compat_callbacks(&pi);
|
153
237
|
|
154
|
-
return oj_pi_parse(argc, argv, &pi, json, len,
|
238
|
+
return oj_pi_parse(argc, argv, &pi, json, len, false);
|
155
239
|
}
|