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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 480e8d68bf5d70f51afeaaf27513e75d5c035b22
4
- data.tar.gz: 4325e7d94beb26b75cadf14b5f167df78bdd1e5a
3
+ metadata.gz: 4f9a694459b58b7e423bd685ea28a1fcfb582a3c
4
+ data.tar.gz: 609715b5ff8e615f59dbdceabdc7ec691c4f8287
5
5
  SHA512:
6
- metadata.gz: c48a73e6ee72bfea2be0744705d81114089455f6eb822f575daa60a3b58346aa194eb051ab744c34fc4a4555d2f768334db8de7dcc4a12118afb41e622e2fe78
7
- data.tar.gz: c6dd31f00e395990f84c19a0d71b5c1ac07d822b24efd772d74e484dc2bd0f045dcee1f44ca251b60fdc938cfa99c7bde0617c06d303acaa2b67f0ec974ff4ac
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
@@ -10,7 +10,7 @@
10
10
 
11
11
  static VALUE symbolize_names_sym;
12
12
 
13
- static const char json_class[] = "json_class";
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 (0 != oj_default_options.create_id) {
623
- if (json_class != oj_default_options.create_id) {
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 = 0;
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 (0 != oj_default_options.create_id) {
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(json_class);
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
- json_class, // create_id
680
+ oj_json_class,// create_id
674
681
  10, // create_id_len
675
682
  3, // sec_prec
676
683
  16, // float_prec
@@ -155,7 +155,7 @@ pthread_mutex_t oj_cache_mutex;
155
155
  VALUE oj_cache_mutex = Qnil;
156
156
  #endif
157
157
 
158
- static const char json_class[] = "json_class";
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
- json_class, // create_id
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 (json_class != oj_default_options.create_id) {
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;
@@ -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
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.0.10'
4
+ VERSION = '3.0.11'
5
5
  end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ %w(lib ext test).each do |dir|
5
+ $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
6
+ end
7
+ require 'rails'
8
+ require 'oj'
9
+
10
+ Oj.mimic_JSON
11
+
12
+ nil.to_json
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.10
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-05-24 00:00:00.000000000 Z
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