oj 2.9.8 → 2.9.9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of oj might be problematic. Click here for more details.
- data/README.md +20 -1
- data/ext/oj/compat.c +2 -0
- data/ext/oj/dump.c +1 -1
- data/ext/oj/object.c +3 -2
- data/ext/oj/oj.c +8 -1
- data/ext/oj/oj.h +3 -0
- data/ext/oj/parse.c +2 -7
- data/ext/oj/parse.h +1 -1
- data/ext/oj/reader.c +17 -24
- data/ext/oj/saj.c +8 -28
- data/ext/oj/scp.c +27 -106
- data/ext/oj/sparse.c +0 -2
- data/ext/oj/strict.c +2 -0
- data/lib/oj/version.rb +1 -1
- data/test/bug.rb +50 -39
- data/test/perf1.rb +64 -0
- data/test/perf2.rb +76 -0
- data/test/perf_obj_old.rb +213 -0
- data/test/test_object.rb +10 -0
- data/test/test_scp.rb +22 -0
- data/test/test_various.rb +1 -1
- metadata +104 -87
- checksums.yaml +0 -7
- data/test/io.rb +0 -48
- data/test/struct.rb +0 -29
- data/test/zip.rb +0 -34
data/test/test_object.rb
CHANGED
@@ -379,6 +379,16 @@ class ObjectJuice < Minitest::Test
|
|
379
379
|
assert(false, "*** expected an exception")
|
380
380
|
end
|
381
381
|
|
382
|
+
def test_json_object_not_hat_hash
|
383
|
+
json = %{{"^#x":[1,2]}}
|
384
|
+
h = Oj.object_load(json)
|
385
|
+
assert_equal({1 => 2}, h);
|
386
|
+
|
387
|
+
json = %{{"~#x":[1,2]}}
|
388
|
+
h = Oj.object_load(json)
|
389
|
+
assert_equal({'~#x' => [1,2]}, h);
|
390
|
+
end
|
391
|
+
|
382
392
|
def test_json_struct
|
383
393
|
unless 'jruby' == RUBY_DESCRIPTION.split(' ')[0]
|
384
394
|
obj = Stuck.new(false, 7)
|
data/test/test_scp.rb
CHANGED
@@ -244,4 +244,26 @@ class ScpTest < Minitest::Test
|
|
244
244
|
end
|
245
245
|
end
|
246
246
|
|
247
|
+
def test_pipe
|
248
|
+
handler = AllHandler.new()
|
249
|
+
json = %{{"one":true,"two":false}}
|
250
|
+
IO.pipe do |read_io, write_io|
|
251
|
+
if fork
|
252
|
+
write_io.close
|
253
|
+
Oj.sc_parse(handler, read_io) {|v| p v}
|
254
|
+
read_io.close
|
255
|
+
assert_equal([[:hash_start],
|
256
|
+
[:hash_set, 'one', true],
|
257
|
+
[:hash_set, 'two', false],
|
258
|
+
[:hash_end],
|
259
|
+
[:add_value, {}]], handler.calls)
|
260
|
+
else
|
261
|
+
read_io.close
|
262
|
+
write_io.write json
|
263
|
+
write_io.close
|
264
|
+
Process.exit(0)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
247
269
|
end
|
data/test/test_various.rb
CHANGED
@@ -897,7 +897,7 @@ class Juice < Minitest::Test
|
|
897
897
|
|
898
898
|
def test_infinity
|
899
899
|
n = Oj.load('Infinity', :mode => :object)
|
900
|
-
assert_equal(
|
900
|
+
assert_equal(BigDecimal.new('Infinity').to_f, n);
|
901
901
|
begin
|
902
902
|
Oj.load('Infinity', :mode => :strict)
|
903
903
|
fail()
|
metadata
CHANGED
@@ -1,111 +1,117 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 57
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 9
|
9
|
+
- 9
|
10
|
+
version: 2.9.9
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Peter Ohler
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
|
18
|
+
date: 2014-07-07 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
14
21
|
name: rake-compiler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.9'
|
20
|
-
type: :development
|
21
22
|
prerelease: false
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '5'
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 25
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 9
|
32
|
+
version: "0.9"
|
34
33
|
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: minitest
|
35
37
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '4'
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 9
|
44
|
+
segments:
|
45
|
+
- 5
|
46
|
+
version: "5"
|
48
47
|
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rails
|
49
51
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 5
|
58
|
+
segments:
|
59
|
+
- 3
|
60
|
+
version: "3"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
description: "The fastest JSON parser and object serializer. "
|
56
64
|
email: peter@ohler.com
|
57
65
|
executables: []
|
58
|
-
|
66
|
+
|
67
|
+
extensions:
|
59
68
|
- ext/oj/extconf.rb
|
60
|
-
extra_rdoc_files:
|
61
|
-
- README.md
|
62
|
-
files:
|
63
|
-
- LICENSE
|
69
|
+
extra_rdoc_files:
|
64
70
|
- README.md
|
71
|
+
files:
|
72
|
+
- lib/oj/bag.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/bag.rb
|
99
|
-
- lib/oj/error.rb
|
100
|
-
- lib/oj/mimic.rb
|
101
|
-
- lib/oj/saj.rb
|
102
|
-
- lib/oj/schandler.rb
|
103
|
-
- lib/oj/version.rb
|
104
111
|
- test/_test_mimic_rails.rb
|
105
112
|
- test/bug.rb
|
106
113
|
- test/files.rb
|
107
114
|
- test/helper.rb
|
108
|
-
- test/io.rb
|
109
115
|
- test/isolated/shared.rb
|
110
116
|
- test/isolated/test_mimic_after.rb
|
111
117
|
- test/isolated/test_mimic_alone.rb
|
@@ -114,15 +120,17 @@ files:
|
|
114
120
|
- test/isolated/test_mimic_rails_after.rb
|
115
121
|
- test/isolated/test_mimic_rails_before.rb
|
116
122
|
- test/perf.rb
|
123
|
+
- test/perf1.rb
|
124
|
+
- test/perf2.rb
|
117
125
|
- test/perf_compat.rb
|
118
126
|
- test/perf_fast.rb
|
119
127
|
- test/perf_file.rb
|
128
|
+
- test/perf_obj_old.rb
|
120
129
|
- test/perf_object.rb
|
121
130
|
- test/perf_saj.rb
|
122
131
|
- test/perf_scp.rb
|
123
132
|
- test/perf_simple.rb
|
124
133
|
- test/perf_strict.rb
|
125
|
-
- test/sample.rb
|
126
134
|
- test/sample/change.rb
|
127
135
|
- test/sample/dir.rb
|
128
136
|
- test/sample/doc.rb
|
@@ -135,8 +143,8 @@ files:
|
|
135
143
|
- test/sample/rect.rb
|
136
144
|
- test/sample/shape.rb
|
137
145
|
- test/sample/text.rb
|
146
|
+
- test/sample.rb
|
138
147
|
- test/sample_json.rb
|
139
|
-
- test/struct.rb
|
140
148
|
- test/test_compat.rb
|
141
149
|
- test/test_debian.rb
|
142
150
|
- test/test_fast.rb
|
@@ -148,34 +156,43 @@ files:
|
|
148
156
|
- test/test_strict.rb
|
149
157
|
- test/test_various.rb
|
150
158
|
- test/test_writer.rb
|
151
|
-
-
|
159
|
+
- LICENSE
|
160
|
+
- README.md
|
152
161
|
homepage: http://www.ohler.com/oj
|
153
|
-
licenses:
|
162
|
+
licenses:
|
154
163
|
- MIT
|
155
164
|
- GPL-3.0
|
156
|
-
metadata: {}
|
157
165
|
post_install_message:
|
158
|
-
rdoc_options:
|
159
|
-
-
|
166
|
+
rdoc_options:
|
167
|
+
- --main
|
160
168
|
- README.md
|
161
|
-
require_paths:
|
169
|
+
require_paths:
|
162
170
|
- lib
|
163
171
|
- ext
|
164
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
-
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
none: false
|
174
|
+
requirements:
|
166
175
|
- - ">="
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
|
169
|
-
|
170
|
-
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
hash: 3
|
178
|
+
segments:
|
179
|
+
- 0
|
180
|
+
version: "0"
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
171
184
|
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
hash: 3
|
187
|
+
segments:
|
188
|
+
- 0
|
189
|
+
version: "0"
|
174
190
|
requirements: []
|
191
|
+
|
175
192
|
rubyforge_project: oj
|
176
|
-
rubygems_version:
|
193
|
+
rubygems_version: 1.8.15
|
177
194
|
signing_key:
|
178
|
-
specification_version:
|
195
|
+
specification_version: 3
|
179
196
|
summary: A fast JSON parser and serializer.
|
180
197
|
test_files: []
|
181
|
-
|
198
|
+
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 080ee5fb844d326ce444282c5df529a135cf125b
|
4
|
-
data.tar.gz: 6461af3c663d8974e0eea8c8b4e3e811500a7397
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 5e241a43f3b733fad07606b48f36ec364fce3a516d59596e9684fd7d87bcbc45ea07321ed37719d95f6803d53877f76443813559a42b6c0c86b0f07d19bd0ee6
|
7
|
-
data.tar.gz: a01b9b8f1f84de6297b5d240c96680dd212851a95d55d6ffced9b1cd79c98553c29e4a9b7358e4c8f2bcc0b080a855cab85dc17cf30bdf9f4f562bf91f5d459c
|
data/test/io.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
$: << File.dirname(__FILE__)
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
class Handler
|
9
|
-
def initialize
|
10
|
-
@state = []
|
11
|
-
end
|
12
|
-
|
13
|
-
def hash_start
|
14
|
-
@state << {}
|
15
|
-
@state.last
|
16
|
-
end
|
17
|
-
|
18
|
-
def hash_end
|
19
|
-
@state.pop
|
20
|
-
end
|
21
|
-
|
22
|
-
def hash_set(h,k,v)
|
23
|
-
h.store(k,v)
|
24
|
-
end
|
25
|
-
|
26
|
-
def array_start
|
27
|
-
@state << []
|
28
|
-
@state.last
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def array_end
|
33
|
-
@state.pop
|
34
|
-
end
|
35
|
-
|
36
|
-
def array_append(a,v)
|
37
|
-
a << v
|
38
|
-
end
|
39
|
-
|
40
|
-
def error(message, line, column); p "ERROR: #{message}" end
|
41
|
-
end
|
42
|
-
|
43
|
-
handler = Handler.new
|
44
|
-
def handler.add_value(v)
|
45
|
-
p v
|
46
|
-
end
|
47
|
-
|
48
|
-
Oj.sc_parse(handler, StringIO.new('{"a":"b","c":[1,2,{"d":"e"}]}[4,5,6]'))
|
data/test/struct.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
# Ubuntu does not accept arguments to ruby when called using env. To get warnings to show up the -w options is
|
5
|
-
# required. That can be set in the RUBYOPT environment variable.
|
6
|
-
# export RUBYOPT=-w
|
7
|
-
|
8
|
-
$VERBOSE = true
|
9
|
-
|
10
|
-
$: << File.join(File.dirname(__FILE__), "../lib")
|
11
|
-
$: << File.join(File.dirname(__FILE__), "../ext")
|
12
|
-
|
13
|
-
require 'oj'
|
14
|
-
|
15
|
-
A = Struct.new(:a,:b,:c,:d)
|
16
|
-
B = Struct.new(:e,:f)
|
17
|
-
|
18
|
-
obj = [A.new(55, B.new(1, 'X'), B.new(2, 'Y'), 3)]
|
19
|
-
|
20
|
-
s = Oj.dump(obj, :mode => :object)
|
21
|
-
|
22
|
-
100000.times do
|
23
|
-
Oj.load(s, :mode => :object)
|
24
|
-
# ds = Oj.dump(o, :mode => :object)
|
25
|
-
# if ds != s
|
26
|
-
# puts ds
|
27
|
-
# raise "holy crap"
|
28
|
-
# end
|
29
|
-
end
|
data/test/zip.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
$: << File.dirname(__FILE__)
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
require 'zlib'
|
9
|
-
|
10
|
-
File.open('test.json.gz', 'r') do |file|
|
11
|
-
Zlib::GzipReader.wrap(file) do |f2|
|
12
|
-
puts "*** f2: #{f2}"
|
13
|
-
Oj.load(f2) do |val|
|
14
|
-
puts val
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
=begin
|
20
|
-
And a json file with the following contents (then gzipped):
|
21
|
-
|
22
|
-
{"a":2}
|
23
|
-
{"b":2}
|
24
|
-
The output is:
|
25
|
-
|
26
|
-
{"a"=>2}
|
27
|
-
{"b"=>2}
|
28
|
-
bin/test:8:in `load': undefined method `new' for #<EOFError: end of file reached> (NoMethodError)
|
29
|
-
from bin/test:8:in `block (2 levels) in <main>'
|
30
|
-
from bin/test:7:in `wrap'
|
31
|
-
from bin/test:7:in `block in <main>'
|
32
|
-
from bin/test:6:in `open'
|
33
|
-
from bin/test:6:in `<main>'
|
34
|
-
=end
|