oj 2.17.3 → 2.17.4
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.
- data/README.md +3 -8
- data/ext/oj/oj.c +11 -0
- data/lib/oj/mimic.rb +38 -2
- data/lib/oj/version.rb +1 -1
- data/test/aaa.rb +21 -0
- data/test/bug.rb +50 -37
- data/test/pact.rb +21 -0
- data/test/perf1.rb +64 -0
- data/test/perf2.rb +76 -0
- data/test/perf_obj_old.rb +213 -0
- data/test/test_bigd.rb +63 -0
- data/test/{mod.rb → test_range.rb} +9 -6
- data/test/test_various.rb +1 -1
- metadata +61 -66
- checksums.yaml +0 -7
- 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/example.rb +0 -11
- data/test/io.rb +0 -48
- data/test/isolated/test_mimic_rails_datetime.rb +0 -27
- data/test/russian.rb +0 -18
- data/test/struct.rb +0 -29
- data/test/test_serializer.rb +0 -59
- data/test/write_timebars.rb +0 -31
data/test/test_bigd.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
$VERBOSE = true
|
5
|
+
|
6
|
+
%w(lib ext test).each do |dir|
|
7
|
+
$LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rubygems' if RUBY_VERSION.start_with?('1.8.')
|
11
|
+
|
12
|
+
#require "minitest/spec"
|
13
|
+
require "minitest/autorun"
|
14
|
+
|
15
|
+
require "oj"
|
16
|
+
|
17
|
+
# Uncomment this line and test_big_decimal will fail
|
18
|
+
require "active_support/json"
|
19
|
+
|
20
|
+
# With ActiveSupport 4.0, neither of these settings affect BigDecimal#to_json,
|
21
|
+
# only BigDecimal#as_json
|
22
|
+
#
|
23
|
+
# ActiveSupport.encode_big_decimal_as_string = false
|
24
|
+
# ActiveSupport::JSON::Encoding.encode_big_decimal_as_string = false
|
25
|
+
|
26
|
+
describe Oj do
|
27
|
+
|
28
|
+
# Options set by default in Rails 4.0 / Rabl
|
29
|
+
def options
|
30
|
+
{
|
31
|
+
:bigdecimal_as_decimal=>true, # default = true
|
32
|
+
:use_to_json=>true, # default = false
|
33
|
+
:mode=>:compat, # default = object
|
34
|
+
:time_format=>:ruby, # default = unix
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_big_decimal
|
39
|
+
orig = BigDecimal.new("3.14159265359")
|
40
|
+
puts "*** to_s: #{orig.to_s}"
|
41
|
+
puts "*** to_json: #{orig.to_json}"
|
42
|
+
puts "*** JSON.dump: #{JSON.dump(orig)}"
|
43
|
+
json = Oj.dump(orig, options)
|
44
|
+
puts "*** json: #{json}"
|
45
|
+
|
46
|
+
value = Oj.load(json)
|
47
|
+
puts "*** value: #{value.class}"
|
48
|
+
assert_equal(value, orig)
|
49
|
+
|
50
|
+
# by default, without active support
|
51
|
+
# assert_equal("0.314159265359E1", json)
|
52
|
+
# in Rails 4.1, with active support
|
53
|
+
# assert_equal("3.14159265359", json)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Floats are unaffected
|
57
|
+
def test_float
|
58
|
+
orig = 3.14159265359
|
59
|
+
json = Oj.dump(orig, options)
|
60
|
+
assert_equal("3.14159265359", json)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -1,16 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: UTF-8
|
3
3
|
|
4
|
+
$VERBOSE = true
|
5
|
+
|
4
6
|
%w(lib ext test).each do |dir|
|
5
7
|
$LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
|
6
8
|
end
|
7
9
|
|
10
|
+
require 'rubygems' if RUBY_VERSION.start_with?('1.8.')
|
8
11
|
require 'oj'
|
9
12
|
|
13
|
+
Oj.mimic_JSON
|
14
|
+
|
15
|
+
#puts Oj.default_options
|
16
|
+
|
17
|
+
range = ("01".."12")
|
10
18
|
|
11
|
-
|
12
|
-
string_io = StringIO.new('{"foo":"bar"}')
|
13
|
-
Oj.load(string_io)
|
14
|
-
string_io.rewind
|
15
|
-
puts string_io.read
|
16
|
-
end.join
|
19
|
+
puts Oj.dump(range)
|
data/test/test_various.rb
CHANGED
metadata
CHANGED
@@ -1,58 +1,65 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.17.
|
4
|
+
version: 2.17.4
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Peter Ohler
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-
|
12
|
+
date: 2016-09-04 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rake-compiler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0.9'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0.9'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: minitest
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '5'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '5'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rails
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '4'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '4'
|
55
|
-
description: 'The fastest JSON parser and object serializer. '
|
62
|
+
description: ! 'The fastest JSON parser and object serializer. '
|
56
63
|
email: peter@ohler.com
|
57
64
|
executables: []
|
58
65
|
extensions:
|
@@ -60,63 +67,55 @@ extensions:
|
|
60
67
|
extra_rdoc_files:
|
61
68
|
- README.md
|
62
69
|
files:
|
63
|
-
-
|
64
|
-
-
|
70
|
+
- lib/oj/active_support_helper.rb
|
71
|
+
- lib/oj/bag.rb
|
72
|
+
- lib/oj/easy_hash.rb
|
73
|
+
- lib/oj/error.rb
|
74
|
+
- lib/oj/mimic.rb
|
75
|
+
- lib/oj/saj.rb
|
76
|
+
- lib/oj/schandler.rb
|
77
|
+
- lib/oj/version.rb
|
78
|
+
- lib/oj.rb
|
79
|
+
- ext/oj/extconf.rb
|
65
80
|
- ext/oj/buf.h
|
66
|
-
- ext/oj/cache8.c
|
67
81
|
- ext/oj/cache8.h
|
68
|
-
- ext/oj/circarray.c
|
69
82
|
- ext/oj/circarray.h
|
83
|
+
- ext/oj/encode.h
|
84
|
+
- ext/oj/err.h
|
85
|
+
- ext/oj/hash.h
|
86
|
+
- ext/oj/odd.h
|
87
|
+
- ext/oj/oj.h
|
88
|
+
- ext/oj/parse.h
|
89
|
+
- ext/oj/reader.h
|
90
|
+
- ext/oj/resolve.h
|
91
|
+
- ext/oj/val_stack.h
|
92
|
+
- ext/oj/cache8.c
|
93
|
+
- ext/oj/circarray.c
|
70
94
|
- ext/oj/compat.c
|
71
95
|
- ext/oj/dump.c
|
72
|
-
- ext/oj/encode.h
|
73
96
|
- ext/oj/err.c
|
74
|
-
- ext/oj/err.h
|
75
|
-
- ext/oj/extconf.rb
|
76
97
|
- ext/oj/fast.c
|
77
98
|
- ext/oj/hash.c
|
78
|
-
- ext/oj/hash.h
|
79
99
|
- ext/oj/hash_test.c
|
80
100
|
- ext/oj/object.c
|
81
101
|
- ext/oj/odd.c
|
82
|
-
- ext/oj/odd.h
|
83
102
|
- ext/oj/oj.c
|
84
|
-
- ext/oj/oj.h
|
85
103
|
- ext/oj/parse.c
|
86
|
-
- ext/oj/parse.h
|
87
104
|
- ext/oj/reader.c
|
88
|
-
- ext/oj/reader.h
|
89
105
|
- ext/oj/resolve.c
|
90
|
-
- ext/oj/resolve.h
|
91
106
|
- ext/oj/saj.c
|
92
107
|
- ext/oj/scp.c
|
93
108
|
- ext/oj/sparse.c
|
94
109
|
- ext/oj/strict.c
|
95
110
|
- ext/oj/val_stack.c
|
96
|
-
- ext/oj/val_stack.h
|
97
|
-
- lib/oj.rb
|
98
|
-
- lib/oj/active_support_helper.rb
|
99
|
-
- lib/oj/bag.rb
|
100
|
-
- lib/oj/easy_hash.rb
|
101
|
-
- lib/oj/error.rb
|
102
|
-
- lib/oj/mimic.rb
|
103
|
-
- lib/oj/saj.rb
|
104
|
-
- lib/oj/schandler.rb
|
105
|
-
- lib/oj/version.rb
|
106
111
|
- test/_test_active.rb
|
107
112
|
- test/_test_active_mimic.rb
|
108
113
|
- test/_test_mimic_rails.rb
|
114
|
+
- test/aaa.rb
|
109
115
|
- test/activesupport_datetime_test.rb
|
110
116
|
- test/bug.rb
|
111
|
-
- test/bug2.rb
|
112
|
-
- test/bug3.rb
|
113
|
-
- test/bug_fast.rb
|
114
|
-
- test/bug_load.rb
|
115
|
-
- test/crash.rb
|
116
|
-
- test/example.rb
|
117
117
|
- test/files.rb
|
118
118
|
- test/helper.rb
|
119
|
-
- test/io.rb
|
120
119
|
- test/isolated/shared.rb
|
121
120
|
- test/isolated/test_mimic_after.rb
|
122
121
|
- test/isolated/test_mimic_alone.rb
|
@@ -125,19 +124,19 @@ files:
|
|
125
124
|
- test/isolated/test_mimic_define.rb
|
126
125
|
- test/isolated/test_mimic_rails_after.rb
|
127
126
|
- test/isolated/test_mimic_rails_before.rb
|
128
|
-
- test/
|
129
|
-
- test/mod.rb
|
127
|
+
- test/pact.rb
|
130
128
|
- test/perf.rb
|
129
|
+
- test/perf1.rb
|
130
|
+
- test/perf2.rb
|
131
131
|
- test/perf_compat.rb
|
132
132
|
- test/perf_fast.rb
|
133
133
|
- test/perf_file.rb
|
134
|
+
- test/perf_obj_old.rb
|
134
135
|
- test/perf_object.rb
|
135
136
|
- test/perf_saj.rb
|
136
137
|
- test/perf_scp.rb
|
137
138
|
- test/perf_simple.rb
|
138
139
|
- test/perf_strict.rb
|
139
|
-
- test/russian.rb
|
140
|
-
- test/sample.rb
|
141
140
|
- test/sample/change.rb
|
142
141
|
- test/sample/dir.rb
|
143
142
|
- test/sample/doc.rb
|
@@ -150,8 +149,9 @@ files:
|
|
150
149
|
- test/sample/rect.rb
|
151
150
|
- test/sample/shape.rb
|
152
151
|
- test/sample/text.rb
|
152
|
+
- test/sample.rb
|
153
153
|
- test/sample_json.rb
|
154
|
-
- test/
|
154
|
+
- test/test_bigd.rb
|
155
155
|
- test/test_compat.rb
|
156
156
|
- test/test_debian.rb
|
157
157
|
- test/test_fast.rb
|
@@ -159,54 +159,50 @@ files:
|
|
159
159
|
- test/test_gc.rb
|
160
160
|
- test/test_hash.rb
|
161
161
|
- test/test_object.rb
|
162
|
+
- test/test_range.rb
|
162
163
|
- test/test_saj.rb
|
163
164
|
- test/test_scp.rb
|
164
|
-
- test/test_serializer.rb
|
165
165
|
- test/test_strict.rb
|
166
166
|
- test/test_various.rb
|
167
167
|
- test/test_writer.rb
|
168
|
-
-
|
168
|
+
- LICENSE
|
169
|
+
- README.md
|
169
170
|
homepage: http://www.ohler.com/oj
|
170
171
|
licenses:
|
171
172
|
- MIT
|
172
|
-
metadata: {}
|
173
173
|
post_install_message:
|
174
174
|
rdoc_options:
|
175
|
-
-
|
175
|
+
- --main
|
176
176
|
- README.md
|
177
177
|
require_paths:
|
178
178
|
- lib
|
179
179
|
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
+
none: false
|
180
181
|
requirements:
|
181
|
-
- -
|
182
|
+
- - ! '>='
|
182
183
|
- !ruby/object:Gem::Version
|
183
184
|
version: '0'
|
184
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
|
+
none: false
|
185
187
|
requirements:
|
186
|
-
- -
|
188
|
+
- - ! '>='
|
187
189
|
- !ruby/object:Gem::Version
|
188
190
|
version: '0'
|
189
191
|
requirements: []
|
190
192
|
rubyforge_project: oj
|
191
|
-
rubygems_version:
|
193
|
+
rubygems_version: 1.8.23.2
|
192
194
|
signing_key:
|
193
|
-
specification_version:
|
195
|
+
specification_version: 3
|
194
196
|
summary: A fast JSON parser and serializer.
|
195
197
|
test_files:
|
196
198
|
- test/_test_active.rb
|
197
199
|
- test/_test_active_mimic.rb
|
198
200
|
- test/_test_mimic_rails.rb
|
201
|
+
- test/aaa.rb
|
199
202
|
- test/activesupport_datetime_test.rb
|
200
203
|
- test/bug.rb
|
201
|
-
- test/bug2.rb
|
202
|
-
- test/bug3.rb
|
203
|
-
- test/bug_fast.rb
|
204
|
-
- test/bug_load.rb
|
205
|
-
- test/crash.rb
|
206
|
-
- test/example.rb
|
207
204
|
- test/files.rb
|
208
205
|
- test/helper.rb
|
209
|
-
- test/io.rb
|
210
206
|
- test/isolated/shared.rb
|
211
207
|
- test/isolated/test_mimic_after.rb
|
212
208
|
- test/isolated/test_mimic_alone.rb
|
@@ -215,18 +211,19 @@ test_files:
|
|
215
211
|
- test/isolated/test_mimic_define.rb
|
216
212
|
- test/isolated/test_mimic_rails_after.rb
|
217
213
|
- test/isolated/test_mimic_rails_before.rb
|
218
|
-
- test/
|
219
|
-
- test/mod.rb
|
214
|
+
- test/pact.rb
|
220
215
|
- test/perf.rb
|
216
|
+
- test/perf1.rb
|
217
|
+
- test/perf2.rb
|
221
218
|
- test/perf_compat.rb
|
222
219
|
- test/perf_fast.rb
|
223
220
|
- test/perf_file.rb
|
221
|
+
- test/perf_obj_old.rb
|
224
222
|
- test/perf_object.rb
|
225
223
|
- test/perf_saj.rb
|
226
224
|
- test/perf_scp.rb
|
227
225
|
- test/perf_simple.rb
|
228
226
|
- test/perf_strict.rb
|
229
|
-
- test/russian.rb
|
230
227
|
- test/sample/change.rb
|
231
228
|
- test/sample/dir.rb
|
232
229
|
- test/sample/doc.rb
|
@@ -241,7 +238,7 @@ test_files:
|
|
241
238
|
- test/sample/text.rb
|
242
239
|
- test/sample.rb
|
243
240
|
- test/sample_json.rb
|
244
|
-
- test/
|
241
|
+
- test/test_bigd.rb
|
245
242
|
- test/test_compat.rb
|
246
243
|
- test/test_debian.rb
|
247
244
|
- test/test_fast.rb
|
@@ -249,11 +246,9 @@ test_files:
|
|
249
246
|
- test/test_gc.rb
|
250
247
|
- test/test_hash.rb
|
251
248
|
- test/test_object.rb
|
249
|
+
- test/test_range.rb
|
252
250
|
- test/test_saj.rb
|
253
251
|
- test/test_scp.rb
|
254
|
-
- test/test_serializer.rb
|
255
252
|
- test/test_strict.rb
|
256
253
|
- test/test_various.rb
|
257
254
|
- test/test_writer.rb
|
258
|
-
- test/write_timebars.rb
|
259
|
-
has_rdoc: true
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: e6db88500e6a8f5b5243b53140952b8956fdad9b
|
4
|
-
data.tar.gz: bd67bf4dd52102f84c728f9349a57a79f28cacd8
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: a85842674b8da8c33f9526c14a675535da412be6f52ad136f6ba48fad5cadf99ec5810ebc076fbf2e27dbda4758b5432dc697a11cdcbff5d7955482dfea92f9c
|
7
|
-
data.tar.gz: d5e3c117f7cea742867e06ca02fdcef961ff6b14c58d9b21979d4df556b780d052bb6de5695ecf9b11d2084091102e752553390bb31d666d6205f39708f52b0b
|
data/test/bug2.rb
DELETED
data/test/bug3.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
#!/usr/bin/env ruby
|
4
|
-
# encoding: UTF-8
|
5
|
-
|
6
|
-
$: << File.dirname(__FILE__)
|
7
|
-
%w(lib ext test).each do |dir|
|
8
|
-
$LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
|
9
|
-
end
|
10
|
-
|
11
|
-
require 'oj'
|
12
|
-
require 'stringio'
|
13
|
-
|
14
|
-
class Parser < Oj::Saj
|
15
|
-
|
16
|
-
def parse(json)
|
17
|
-
Oj.saj_parse(self, StringIO.new(json))
|
18
|
-
end
|
19
|
-
|
20
|
-
def hash_start(key)
|
21
|
-
puts "START: #{key}"
|
22
|
-
end
|
23
|
-
|
24
|
-
def error(message, line, column)
|
25
|
-
puts "Error callback: #{message}"
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
parser = Parser.new
|
31
|
-
|
32
|
-
begin
|
33
|
-
# truncated JSON, Oj.saj_parse raises, #error not called
|
34
|
-
parser.parse('{"foo{"bar":')
|
35
|
-
rescue Exception => e
|
36
|
-
puts "*** #{e.class}: #{e.message}"
|
37
|
-
end
|
38
|
-
|
39
|
-
puts "\n\n"
|
40
|
-
|
41
|
-
begin
|
42
|
-
# invalid JSON, doesn't raise an error
|
43
|
-
parser.parse('{"foo":{"bar":}')
|
44
|
-
rescue Exception => e
|
45
|
-
puts "*** #{e.class}: #{e.message}"
|
46
|
-
end
|