oj 3.0.10 → 3.0.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/README.md +0 -2
- data/ext/oj/mimic_json.c +15 -8
- data/ext/oj/oj.c +3 -3
- data/ext/oj/rails.c +1 -1
- data/lib/oj/version.rb +1 -1
- data/test/bug.rb +12 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f9a694459b58b7e423bd685ea28a1fcfb582a3c
|
4
|
+
data.tar.gz: 609715b5ff8e615f59dbdceabdc7ec691c4f8287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad438e894a9540489bbc29c75d39972db15389e41b83700467736b3b1fb7e329c11def32cabc6753b2e60ae1a548f5fd5c89074057c4b6c8816b014c9fb5bd5d
|
7
|
+
data.tar.gz: b25cdb2139bea0f973b80c421c956f0ecece0c50b70f6b87707f52ac452d418672d8e865026020804cb5bc69434ed3e0214c3034df116bba540ef955aa07c0d7
|
data/README.md
CHANGED
@@ -7,8 +7,6 @@ A *fast* JSON parser and Object marshaller as a Ruby gem.
|
|
7
7
|
Version 3.0 is out! 3.0 provides better json gem and Rails compatibility. It
|
8
8
|
also provides additional optimization options.
|
9
9
|
|
10
|
-
Please check out issue #364 and help pick or suggest a image to represent Oj.
|
11
|
-
|
12
10
|
## Using
|
13
11
|
|
14
12
|
```ruby
|
data/ext/oj/mimic_json.c
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
static VALUE symbolize_names_sym;
|
12
12
|
|
13
|
-
|
13
|
+
extern const char oj_json_class[];
|
14
14
|
|
15
15
|
VALUE oj_array_nl_sym;
|
16
16
|
VALUE oj_ascii_only_sym;
|
@@ -155,6 +155,9 @@ oj_parse_mimic_dump_options(VALUE ropts, Options copts) {
|
|
155
155
|
copts->dump_opts.array_size = (uint8_t)len;
|
156
156
|
copts->dump_opts.use = true;
|
157
157
|
}
|
158
|
+
if (Qnil != (v = rb_hash_lookup(ropts, oj_quirks_mode_sym))) {
|
159
|
+
copts->quirks_mode = (Qtrue == v) ? Yes : No;
|
160
|
+
}
|
158
161
|
if (Qnil != (v = rb_hash_lookup(ropts, oj_ascii_only_sym))) {
|
159
162
|
// generate seems to assume anything except nil and false are true.
|
160
163
|
if (Qfalse == v) {
|
@@ -198,9 +201,11 @@ mimic_dump(int argc, VALUE *argv, VALUE self) {
|
|
198
201
|
out.allocated = 0;
|
199
202
|
out.caller = CALLER_DUMP;
|
200
203
|
|
204
|
+
/* seems like this is not correct
|
201
205
|
if (No == copts.nilnil && Qnil == *argv) {
|
202
206
|
rb_raise(rb_eTypeError, "nil not allowed.");
|
203
207
|
}
|
208
|
+
*/
|
204
209
|
copts.dump_opts.max_depth = MAX_DEPTH; // when using dump there is no limit
|
205
210
|
out.omit_nil = copts.dump_opts.omit_nil;
|
206
211
|
if (2 <= argc) {
|
@@ -347,7 +352,7 @@ mimic_generate_core(int argc, VALUE *argv, Options copts) {
|
|
347
352
|
char buf[4096];
|
348
353
|
struct _Out out;
|
349
354
|
VALUE rstr;
|
350
|
-
|
355
|
+
|
351
356
|
out.buf = buf;
|
352
357
|
out.end = buf + sizeof(buf) - 10;
|
353
358
|
out.allocated = 0;
|
@@ -360,9 +365,11 @@ mimic_generate_core(int argc, VALUE *argv, Options copts) {
|
|
360
365
|
if (2 == argc && Qnil != argv[1]) {
|
361
366
|
oj_parse_mimic_dump_options(argv[1], copts);
|
362
367
|
}
|
368
|
+
/* seems like this is not correct
|
363
369
|
if (No == copts->nilnil && Qnil == *argv) {
|
364
370
|
rb_raise(rb_eTypeError, "nil not allowed.");
|
365
371
|
}
|
372
|
+
*/
|
366
373
|
oj_dump_obj_to_json_using_params(*argv, copts, &out, argc - 1, argv + 1);
|
367
374
|
|
368
375
|
if (0 == out.buf) {
|
@@ -619,11 +626,11 @@ static VALUE
|
|
619
626
|
mimic_set_create_id(VALUE self, VALUE id) {
|
620
627
|
Check_Type(id, T_STRING);
|
621
628
|
|
622
|
-
if (
|
623
|
-
if (
|
629
|
+
if (NULL != oj_default_options.create_id) {
|
630
|
+
if (oj_json_class != oj_default_options.create_id && NULL != oj_default_options.create_id) {
|
624
631
|
xfree((char*)oj_default_options.create_id);
|
625
632
|
}
|
626
|
-
oj_default_options.create_id =
|
633
|
+
oj_default_options.create_id = NULL;
|
627
634
|
oj_default_options.create_id_len = 0;
|
628
635
|
}
|
629
636
|
if (Qnil != id) {
|
@@ -643,10 +650,10 @@ mimic_set_create_id(VALUE self, VALUE id) {
|
|
643
650
|
*/
|
644
651
|
static VALUE
|
645
652
|
mimic_create_id(VALUE self) {
|
646
|
-
if (
|
653
|
+
if (NULL != oj_default_options.create_id) {
|
647
654
|
return oj_encode(rb_str_new_cstr(oj_default_options.create_id));
|
648
655
|
}
|
649
|
-
return rb_str_new_cstr(
|
656
|
+
return rb_str_new_cstr(oj_json_class);
|
650
657
|
}
|
651
658
|
|
652
659
|
static struct _Options mimic_object_to_json_options = {
|
@@ -670,7 +677,7 @@ static struct _Options mimic_object_to_json_options = {
|
|
670
677
|
No, // allow_invalid
|
671
678
|
No, // create_ok
|
672
679
|
No, // allow_nan
|
673
|
-
|
680
|
+
oj_json_class,// create_id
|
674
681
|
10, // create_id_len
|
675
682
|
3, // sec_prec
|
676
683
|
16, // float_prec
|
data/ext/oj/oj.c
CHANGED
@@ -155,7 +155,7 @@ pthread_mutex_t oj_cache_mutex;
|
|
155
155
|
VALUE oj_cache_mutex = Qnil;
|
156
156
|
#endif
|
157
157
|
|
158
|
-
|
158
|
+
const char oj_json_class[] = "json_class";
|
159
159
|
|
160
160
|
struct _Options oj_default_options = {
|
161
161
|
0, // indent
|
@@ -178,7 +178,7 @@ struct _Options oj_default_options = {
|
|
178
178
|
No, // allow_invalid
|
179
179
|
No, // create_ok
|
180
180
|
Yes, // allow_nan
|
181
|
-
|
181
|
+
oj_json_class, // create_id
|
182
182
|
10, // create_id_len
|
183
183
|
9, // sec_prec
|
184
184
|
16, // float_prec
|
@@ -521,7 +521,7 @@ oj_parse_options(VALUE ropts, Options copts) {
|
|
521
521
|
if (Qtrue == rb_funcall(ropts, oj_has_key_id, 1, create_id_sym)) {
|
522
522
|
v = rb_hash_lookup(ropts, create_id_sym);
|
523
523
|
if (Qnil == v) {
|
524
|
-
if (
|
524
|
+
if (oj_json_class != oj_default_options.create_id && NULL != copts->create_id) {
|
525
525
|
xfree((char*)oj_default_options.create_id);
|
526
526
|
}
|
527
527
|
copts->create_id = NULL;
|
data/ext/oj/rails.c
CHANGED
@@ -760,7 +760,7 @@ rails_time_precision(VALUE self, VALUE prec) {
|
|
760
760
|
}
|
761
761
|
|
762
762
|
/* Document-method: set_encoder
|
763
|
-
*call-seq: set_encoder()
|
763
|
+
* call-seq: set_encoder()
|
764
764
|
*
|
765
765
|
* Sets the ActiveSupport.encoder to Oj::Rails::Encoder and wraps some of the
|
766
766
|
* formatting globals used by ActiveSupport to allow the use of those globals
|
data/lib/oj/version.rb
CHANGED
data/test/bug.rb
ADDED
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.11
|
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-
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- test/activesupport5/encoding_test_cases.rb
|
150
150
|
- test/activesupport5/test_helper.rb
|
151
151
|
- test/activesupport5/time_zone_test_helpers.rb
|
152
|
+
- test/bug.rb
|
152
153
|
- test/files.rb
|
153
154
|
- test/helper.rb
|
154
155
|
- test/isolated/shared.rb
|
@@ -250,6 +251,7 @@ test_files:
|
|
250
251
|
- test/activesupport5/encoding_test_cases.rb
|
251
252
|
- test/activesupport5/test_helper.rb
|
252
253
|
- test/activesupport5/time_zone_test_helpers.rb
|
254
|
+
- test/bug.rb
|
253
255
|
- test/files.rb
|
254
256
|
- test/helper.rb
|
255
257
|
- test/isolated/shared.rb
|