oj 3.3.2 → 3.3.3
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 +1 -1
- data/ext/oj/extconf.rb +2 -2
- data/ext/oj/mimic_json.c +3 -1
- data/ext/oj/object.c +14 -8
- data/ext/oj/oj.c +20 -18
- data/lib/oj/version.rb +1 -1
- data/test/bug.rb +22 -0
- data/test/test_file.rb +2 -0
- data/test/test_object.rb +5 -10
- data/test/test_scp.rb +6 -0
- metadata +70 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e210bbe1a4ca6481764cdbce1cf22a81cef57422
|
4
|
+
data.tar.gz: 498f055ca85353c634d9075ebfd4aa08b407ec9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ef63f7e0e438b91403adc11f8789ee0637a093e77f189713e2a1c8302eb4ba2b5a85c1a212a0773a9d51d6b53e799ef23f5a24bf1ef5ada26ef6c4cd1607eec
|
7
|
+
data.tar.gz: 22439e9541f4cee3f2524c4fecf114bb69f90693fddd4527f4ba56d632f060803ac021b745abeca80f45c7ab0171ac94159f98428e527e24e3eba3971c40e3af
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# [](http://www.ohler.com/oj) gem
|
2
2
|
|
3
|
-
[](http://travis-ci.org/ohler55/oj?branch=master)  
|
3
|
+
[](http://travis-ci.org/ohler55/oj?branch=master) [](https://ci.appveyor.com/project/ohler55/oj)  
|
4
4
|
|
5
5
|
A *fast* JSON parser and Object marshaller as a Ruby gem.
|
6
6
|
|
data/ext/oj/extconf.rb
CHANGED
data/ext/oj/mimic_json.c
CHANGED
@@ -92,6 +92,8 @@ oj_parse_mimic_dump_options(VALUE ropts, Options copts) {
|
|
92
92
|
ropts = rb_funcall(ropts, oj_to_hash_id, 0);
|
93
93
|
} else if (rb_respond_to(ropts, oj_to_h_id)) {
|
94
94
|
ropts = rb_funcall(ropts, oj_to_h_id, 0);
|
95
|
+
} else if (Qnil == ropts) {
|
96
|
+
return;
|
95
97
|
} else {
|
96
98
|
rb_raise(rb_eArgError, "options must be a hash.");
|
97
99
|
}
|
@@ -505,7 +507,7 @@ mimic_parse_core(int argc, VALUE *argv, VALUE self, bool bang) {
|
|
505
507
|
pi.options.mode = CompatMode;
|
506
508
|
pi.max_depth = 100;
|
507
509
|
|
508
|
-
if (2 <= argc) {
|
510
|
+
if (2 <= argc && Qnil != argv[1]) {
|
509
511
|
VALUE ropts = argv[1];
|
510
512
|
VALUE v;
|
511
513
|
|
data/ext/oj/object.c
CHANGED
@@ -294,14 +294,20 @@ hat_num(ParseInfo pi, Val parent, Val kval, NumInfo ni) {
|
|
294
294
|
struct tm *st = gmtime(&t);
|
295
295
|
VALUE args[8];
|
296
296
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
297
|
+
// Windows does not support dates before 1970 so ignore
|
298
|
+
// the zone and do the best we can.
|
299
|
+
if (NULL == st) {
|
300
|
+
parent->val = rb_time_nano_new(ni->i, (long)nsec);
|
301
|
+
} else {
|
302
|
+
args[0] = LONG2NUM((long)(1900 + st->tm_year));
|
303
|
+
args[1] = LONG2NUM(1 + st->tm_mon);
|
304
|
+
args[2] = LONG2NUM(st->tm_mday);
|
305
|
+
args[3] = LONG2NUM(st->tm_hour);
|
306
|
+
args[4] = LONG2NUM(st->tm_min);
|
307
|
+
args[5] = rb_float_new((double)st->tm_sec + ((double)nsec + 0.5) / 1000000000.0);
|
308
|
+
args[6] = LONG2NUM(ni->exp);
|
309
|
+
parent->val = rb_funcall2(rb_cTime, oj_new_id, 7, args);
|
310
|
+
}
|
305
311
|
} else {
|
306
312
|
parent->val = rb_time_nano_new(ni->i, (long)nsec);
|
307
313
|
}
|
data/ext/oj/oj.c
CHANGED
@@ -749,24 +749,26 @@ load(int argc, VALUE *argv, VALUE self) {
|
|
749
749
|
VALUE ropts = argv[1];
|
750
750
|
VALUE v;
|
751
751
|
|
752
|
-
|
753
|
-
|
754
|
-
if (
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
752
|
+
if (Qnil != ropts || CompatMode != mode) {
|
753
|
+
Check_Type(ropts, T_HASH);
|
754
|
+
if (Qnil != (v = rb_hash_lookup(ropts, mode_sym))) {
|
755
|
+
if (object_sym == v) {
|
756
|
+
mode = ObjectMode;
|
757
|
+
} else if (strict_sym == v) {
|
758
|
+
mode = StrictMode;
|
759
|
+
} else if (compat_sym == v || json_sym == v) {
|
760
|
+
mode = CompatMode;
|
761
|
+
} else if (null_sym == v) {
|
762
|
+
mode = NullMode;
|
763
|
+
} else if (custom_sym == v) {
|
764
|
+
mode = CustomMode;
|
765
|
+
} else if (rails_sym == v) {
|
766
|
+
mode = RailsMode;
|
767
|
+
} else if (wab_sym == v) {
|
768
|
+
mode = WabMode;
|
769
|
+
} else {
|
770
|
+
rb_raise(rb_eArgError, ":mode must be :object, :strict, :compat, :null, :custom, :rails, or :wab.");
|
771
|
+
}
|
770
772
|
}
|
771
773
|
}
|
772
774
|
}
|
data/lib/oj/version.rb
CHANGED
data/test/bug.rb
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
+
|
8
|
+
#require 'rails'
|
9
|
+
#require 'active_support/json'
|
10
|
+
require 'oj'
|
11
|
+
|
12
|
+
#Oj.optimize_rails
|
13
|
+
|
14
|
+
#puts JSON.parse('{"a":1}', symbolize_names: true)
|
15
|
+
|
16
|
+
#Oj.mimic_JSON()
|
17
|
+
|
18
|
+
#puts Oj.dump({nan: Float::NAN}, mode: :compat, nan: :raise)
|
19
|
+
|
20
|
+
#puts({nan: Float::NAN}.to_json)
|
21
|
+
|
22
|
+
puts Oj.dump(NoMethodError.new, mode: :custom)
|
data/test/test_file.rb
CHANGED
@@ -130,6 +130,8 @@ class FileJuice < Minitest::Test
|
|
130
130
|
dump_and_load(t, false)
|
131
131
|
end
|
132
132
|
def test_time_object_early
|
133
|
+
# Windows does not support dates before 1970.
|
134
|
+
return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
|
133
135
|
t = Time.xmlschema("1954-01-05T00:00:00.123456")
|
134
136
|
Oj.default_options = { :mode => :object, :time_format => :unix_zone }
|
135
137
|
dump_and_load(t, false)
|
data/test/test_object.rb
CHANGED
@@ -568,11 +568,10 @@ class ObjectJuice < Minitest::Test
|
|
568
568
|
end
|
569
569
|
|
570
570
|
def test_time_early
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
end
|
571
|
+
# Windows does not support dates before 1970.
|
572
|
+
return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
|
573
|
+
|
574
|
+
t = Time.new(1954, 1, 5, 21, 37, 7.123456789, -8 * 3600)
|
576
575
|
# The fractional seconds are not always recreated exactly which causes a
|
577
576
|
# mismatch so instead the seconds, nsecs, and gmt_offset are checked
|
578
577
|
# separately along with utc.
|
@@ -590,11 +589,7 @@ class ObjectJuice < Minitest::Test
|
|
590
589
|
end
|
591
590
|
|
592
591
|
def test_time_unix_zone
|
593
|
-
|
594
|
-
t = Time.parse('2015-01-05T21:37:07.123456789-08:00')
|
595
|
-
else
|
596
|
-
t = Time.new(2015, 1, 5, 21, 37, 7.123456789, -8 * 3600)
|
597
|
-
end
|
592
|
+
t = Time.new(2015, 1, 5, 21, 37, 7.123456789, -8 * 3600)
|
598
593
|
# The fractional seconds are not always recreated exactly which causes a
|
599
594
|
# mismatch so instead the seconds, nsecs, and gmt_offset are checked
|
600
595
|
# separately along with utc.
|
data/test/test_scp.rb
CHANGED
@@ -320,6 +320,9 @@ class ScpTest < Minitest::Test
|
|
320
320
|
end
|
321
321
|
|
322
322
|
def test_pipe
|
323
|
+
# Windows does not support fork
|
324
|
+
return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
|
325
|
+
|
323
326
|
handler = AllHandler.new()
|
324
327
|
json = %{{"one":true,"two":false}}
|
325
328
|
IO.pipe do |read_io, write_io|
|
@@ -344,6 +347,9 @@ class ScpTest < Minitest::Test
|
|
344
347
|
end
|
345
348
|
|
346
349
|
def test_pipe_close
|
350
|
+
# Windows does not support fork
|
351
|
+
return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
|
352
|
+
|
347
353
|
json = %{{"one":true,"two":false}}
|
348
354
|
IO.pipe do |read_io, write_io|
|
349
355
|
if fork
|
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.3.
|
4
|
+
version: 3.3.3
|
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-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -60,15 +60,15 @@ extensions:
|
|
60
60
|
extra_rdoc_files:
|
61
61
|
- README.md
|
62
62
|
- pages/Advanced.md
|
63
|
-
- pages/WAB.md
|
64
|
-
- pages/Encoding.md
|
65
|
-
- pages/Modes.md
|
66
|
-
- pages/Security.md
|
67
|
-
- pages/JsonGem.md
|
68
|
-
- pages/Rails.md
|
69
63
|
- pages/Compatibility.md
|
70
64
|
- pages/Custom.md
|
65
|
+
- pages/Encoding.md
|
66
|
+
- pages/JsonGem.md
|
67
|
+
- pages/Modes.md
|
71
68
|
- pages/Options.md
|
69
|
+
- pages/Rails.md
|
70
|
+
- pages/Security.md
|
71
|
+
- pages/WAB.md
|
72
72
|
files:
|
73
73
|
- LICENSE
|
74
74
|
- README.md
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- test/activesupport5/encoding_test_cases.rb
|
153
153
|
- test/activesupport5/test_helper.rb
|
154
154
|
- test/activesupport5/time_zone_test_helpers.rb
|
155
|
+
- test/bug.rb
|
155
156
|
- test/files.rb
|
156
157
|
- test/helper.rb
|
157
158
|
- test/isolated/shared.rb
|
@@ -244,77 +245,78 @@ signing_key:
|
|
244
245
|
specification_version: 4
|
245
246
|
summary: A fast JSON parser and serializer.
|
246
247
|
test_files:
|
247
|
-
- test/
|
248
|
-
- test/
|
248
|
+
- test/_test_active.rb
|
249
|
+
- test/_test_active_mimic.rb
|
250
|
+
- test/_test_mimic_rails.rb
|
251
|
+
- test/activesupport4/decoding_test.rb
|
252
|
+
- test/activesupport4/encoding_test.rb
|
253
|
+
- test/activesupport4/test_helper.rb
|
249
254
|
- test/activesupport5/decoding_test.rb
|
250
|
-
- test/activesupport5/encoding_test_cases.rb
|
251
255
|
- test/activesupport5/encoding_test.rb
|
252
|
-
- test/
|
256
|
+
- test/activesupport5/encoding_test_cases.rb
|
257
|
+
- test/activesupport5/test_helper.rb
|
258
|
+
- test/activesupport5/time_zone_test_helpers.rb
|
259
|
+
- test/bug.rb
|
253
260
|
- test/files.rb
|
261
|
+
- test/helper.rb
|
262
|
+
- test/isolated/shared.rb
|
263
|
+
- test/isolated/test_mimic_after.rb
|
264
|
+
- test/isolated/test_mimic_alone.rb
|
265
|
+
- test/isolated/test_mimic_as_json.rb
|
266
|
+
- test/isolated/test_mimic_before.rb
|
267
|
+
- test/isolated/test_mimic_define.rb
|
268
|
+
- test/isolated/test_mimic_rails_after.rb
|
269
|
+
- test/isolated/test_mimic_rails_before.rb
|
270
|
+
- test/isolated/test_mimic_redefine.rb
|
271
|
+
- test/json_gem/json_addition_test.rb
|
272
|
+
- test/json_gem/json_common_interface_test.rb
|
273
|
+
- test/json_gem/json_encoding_test.rb
|
274
|
+
- test/json_gem/json_ext_parser_test.rb
|
275
|
+
- test/json_gem/json_fixtures_test.rb
|
276
|
+
- test/json_gem/json_generator_test.rb
|
277
|
+
- test/json_gem/json_generic_object_test.rb
|
278
|
+
- test/json_gem/json_parser_test.rb
|
279
|
+
- test/json_gem/json_string_matching_test.rb
|
280
|
+
- test/json_gem/test_helper.rb
|
281
|
+
- test/perf.rb
|
282
|
+
- test/perf_compat.rb
|
283
|
+
- test/perf_fast.rb
|
284
|
+
- test/perf_file.rb
|
285
|
+
- test/perf_object.rb
|
286
|
+
- test/perf_saj.rb
|
254
287
|
- test/perf_scp.rb
|
255
|
-
- test/
|
256
|
-
- test/
|
257
|
-
- test/
|
258
|
-
- test/
|
259
|
-
- test/
|
288
|
+
- test/perf_simple.rb
|
289
|
+
- test/perf_strict.rb
|
290
|
+
- test/perf_wab.rb
|
291
|
+
- test/sample/change.rb
|
292
|
+
- test/sample/dir.rb
|
293
|
+
- test/sample/doc.rb
|
260
294
|
- test/sample/file.rb
|
295
|
+
- test/sample/group.rb
|
261
296
|
- test/sample/hasprops.rb
|
262
297
|
- test/sample/layer.rb
|
263
|
-
- test/sample/
|
264
|
-
- test/sample/doc.rb
|
298
|
+
- test/sample/line.rb
|
265
299
|
- test/sample/oval.rb
|
300
|
+
- test/sample/rect.rb
|
266
301
|
- test/sample/shape.rb
|
267
302
|
- test/sample/text.rb
|
268
|
-
- test/sample/group.rb
|
269
|
-
- test/sample/dir.rb
|
270
|
-
- test/sample/line.rb
|
271
|
-
- test/sample/rect.rb
|
272
|
-
- test/tests.rb
|
273
|
-
- test/test_object.rb
|
274
|
-
- test/perf_wab.rb
|
275
|
-
- test/tests_mimic.rb
|
276
|
-
- test/perf_saj.rb
|
277
|
-
- test/tests_mimic_addition.rb
|
278
|
-
- test/test_saj.rb
|
279
303
|
- test/sample.rb
|
280
|
-
- test/test_scp.rb
|
281
|
-
- test/perf_object.rb
|
282
|
-
- test/perf_simple.rb
|
283
|
-
- test/test_null.rb
|
284
|
-
- test/_test_active_mimic.rb
|
285
|
-
- test/_test_active.rb
|
286
|
-
- test/test_compat.rb
|
287
304
|
- test/sample_json.rb
|
288
|
-
- test/
|
289
|
-
- test/json_gem/json_generic_object_test.rb
|
290
|
-
- test/json_gem/json_common_interface_test.rb
|
291
|
-
- test/json_gem/json_string_matching_test.rb
|
292
|
-
- test/json_gem/json_addition_test.rb
|
293
|
-
- test/json_gem/json_fixtures_test.rb
|
294
|
-
- test/json_gem/json_generator_test.rb
|
295
|
-
- test/json_gem/json_ext_parser_test.rb
|
296
|
-
- test/json_gem/json_parser_test.rb
|
297
|
-
- test/json_gem/json_encoding_test.rb
|
298
|
-
- test/helper.rb
|
299
|
-
- test/activesupport4/test_helper.rb
|
300
|
-
- test/activesupport4/decoding_test.rb
|
301
|
-
- test/activesupport4/encoding_test.rb
|
302
|
-
- test/test_wab.rb
|
303
|
-
- test/perf_file.rb
|
304
|
-
- test/perf_compat.rb
|
305
|
-
- test/test_various.rb
|
306
|
-
- test/test_strict.rb
|
305
|
+
- test/test_compat.rb
|
307
306
|
- test/test_custom.rb
|
308
|
-
- test/
|
309
|
-
- test/perf_fast.rb
|
310
|
-
- test/isolated/test_mimic_alone.rb
|
311
|
-
- test/isolated/test_mimic_after.rb
|
312
|
-
- test/isolated/test_mimic_as_json.rb
|
313
|
-
- test/isolated/test_mimic_rails_after.rb
|
314
|
-
- test/isolated/test_mimic_before.rb
|
315
|
-
- test/isolated/test_mimic_rails_before.rb
|
316
|
-
- test/isolated/test_mimic_define.rb
|
317
|
-
- test/isolated/shared.rb
|
318
|
-
- test/isolated/test_mimic_redefine.rb
|
319
|
-
- test/perf.rb
|
307
|
+
- test/test_debian.rb
|
320
308
|
- test/test_fast.rb
|
309
|
+
- test/test_file.rb
|
310
|
+
- test/test_gc.rb
|
311
|
+
- test/test_hash.rb
|
312
|
+
- test/test_null.rb
|
313
|
+
- test/test_object.rb
|
314
|
+
- test/test_saj.rb
|
315
|
+
- test/test_scp.rb
|
316
|
+
- test/test_strict.rb
|
317
|
+
- test/test_various.rb
|
318
|
+
- test/test_wab.rb
|
319
|
+
- test/test_writer.rb
|
320
|
+
- test/tests.rb
|
321
|
+
- test/tests_mimic.rb
|
322
|
+
- test/tests_mimic_addition.rb
|