oj 2.9.9 → 2.10.0
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.
Potentially problematic release.
This version of oj might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +10 -23
- data/ext/oj/compat.c +14 -8
- data/ext/oj/dump.c +2 -2
- data/ext/oj/object.c +39 -28
- data/ext/oj/oj.c +3 -1
- data/ext/oj/oj.h +1 -0
- data/ext/oj/parse.c +25 -16
- data/ext/oj/parse.h +4 -3
- data/ext/oj/scp.c +29 -15
- data/ext/oj/sparse.c +13 -7
- data/ext/oj/strict.c +17 -8
- data/ext/oj/val_stack.c +1 -0
- data/ext/oj/val_stack.h +3 -1
- data/lib/oj/schandler.rb +11 -0
- data/lib/oj/version.rb +1 -1
- data/test/bug.rb +40 -51
- data/test/bug2.rb +10 -0
- data/test/io.rb +48 -0
- data/test/struct.rb +29 -0
- data/test/test_compat.rb +2 -0
- data/test/test_file.rb +2 -0
- data/test/test_object.rb +2 -0
- data/test/test_scp.rb +42 -5
- data/test/test_strict.rb +2 -0
- data/test/test_various.rb +2 -0
- data/test/write_timebars.rb +31 -0
- data/test/zip.rb +34 -0
- metadata +89 -104
- data/test/perf1.rb +0 -64
- data/test/perf2.rb +0 -76
- data/test/perf_obj_old.rb +0 -213
data/test/test_strict.rb
CHANGED
@@ -39,6 +39,8 @@ class StrictJuice < Minitest::Test
|
|
39
39
|
dump_and_load(12345.6789, false)
|
40
40
|
dump_and_load(70.35, false)
|
41
41
|
dump_and_load(-54321.012, false)
|
42
|
+
dump_and_load(1.7775, false)
|
43
|
+
dump_and_load(2.5024, false)
|
42
44
|
dump_and_load(2.48e16, false)
|
43
45
|
dump_and_load(2.48e100 * 1.0e10, false)
|
44
46
|
dump_and_load(-2.48e100 * 1.0e10, false)
|
data/test/test_various.rb
CHANGED
@@ -173,6 +173,8 @@ class Juice < Minitest::Test
|
|
173
173
|
dump_and_load(12345.6789, false)
|
174
174
|
dump_and_load(70.35, false)
|
175
175
|
dump_and_load(-54321.012, false)
|
176
|
+
dump_and_load(1.7775, false)
|
177
|
+
dump_and_load(2.5024, false)
|
176
178
|
dump_and_load(2.48e16, false)
|
177
179
|
dump_and_load(2.48e100 * 1.0e10, false)
|
178
180
|
dump_and_load(-2.48e100 * 1.0e10, false)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
%w(lib ext).each do |dir|
|
5
|
+
$LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'stringio'
|
9
|
+
require 'oj'
|
10
|
+
|
11
|
+
|
12
|
+
filename = File.join(File.dirname(__FILE__), 'day.json')
|
13
|
+
File.open(filename, "w") do |f|
|
14
|
+
w = Oj::StreamWriter.new(f, :indent => -1)
|
15
|
+
390.times do |i|
|
16
|
+
w.push_object()
|
17
|
+
w.push_value(12, 'msgType')
|
18
|
+
w.push_value(1, 'version')
|
19
|
+
w.push_value(1_400_074_200 + i * 60, 'bar')
|
20
|
+
w.push_value('TBC', 'source')
|
21
|
+
w.push_array('timebars')
|
22
|
+
w.push_object()
|
23
|
+
w.push_value('aapl_24', 'asset')
|
24
|
+
w.push_value(91.87, 'close')
|
25
|
+
w.pop()
|
26
|
+
w.pop()
|
27
|
+
w.pop()
|
28
|
+
end
|
29
|
+
f.write("\n")
|
30
|
+
end
|
31
|
+
|
data/test/zip.rb
ADDED
@@ -0,0 +1,34 @@
|
|
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
|
metadata
CHANGED
@@ -1,117 +1,112 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 9
|
9
|
-
- 9
|
10
|
-
version: 2.9.9
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.10.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Peter Ohler
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-08-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: rake-compiler
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 25
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 9
|
32
|
-
version: "0.9"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
33
20
|
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: minitest
|
37
21
|
prerelease: false
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5'
|
47
34
|
type: :development
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rails
|
51
35
|
prerelease: false
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4'
|
61
48
|
type: :development
|
62
|
-
|
63
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4'
|
55
|
+
description: 'The fastest JSON parser and object serializer. '
|
64
56
|
email: peter@ohler.com
|
65
57
|
executables: []
|
66
|
-
|
67
|
-
extensions:
|
58
|
+
extensions:
|
68
59
|
- ext/oj/extconf.rb
|
69
|
-
extra_rdoc_files:
|
60
|
+
extra_rdoc_files:
|
61
|
+
- README.md
|
62
|
+
files:
|
63
|
+
- LICENSE
|
70
64
|
- 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
|
80
65
|
- ext/oj/buf.h
|
81
|
-
- ext/oj/cache8.h
|
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
66
|
- ext/oj/cache8.c
|
67
|
+
- ext/oj/cache8.h
|
93
68
|
- ext/oj/circarray.c
|
69
|
+
- ext/oj/circarray.h
|
94
70
|
- ext/oj/compat.c
|
95
71
|
- ext/oj/dump.c
|
72
|
+
- ext/oj/encode.h
|
96
73
|
- ext/oj/err.c
|
74
|
+
- ext/oj/err.h
|
75
|
+
- ext/oj/extconf.rb
|
97
76
|
- ext/oj/fast.c
|
98
77
|
- ext/oj/hash.c
|
78
|
+
- ext/oj/hash.h
|
99
79
|
- ext/oj/hash_test.c
|
100
80
|
- ext/oj/object.c
|
101
81
|
- ext/oj/odd.c
|
82
|
+
- ext/oj/odd.h
|
102
83
|
- ext/oj/oj.c
|
84
|
+
- ext/oj/oj.h
|
103
85
|
- ext/oj/parse.c
|
86
|
+
- ext/oj/parse.h
|
104
87
|
- ext/oj/reader.c
|
88
|
+
- ext/oj/reader.h
|
105
89
|
- ext/oj/resolve.c
|
90
|
+
- ext/oj/resolve.h
|
106
91
|
- ext/oj/saj.c
|
107
92
|
- ext/oj/scp.c
|
108
93
|
- ext/oj/sparse.c
|
109
94
|
- ext/oj/strict.c
|
110
95
|
- 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
|
111
104
|
- test/_test_mimic_rails.rb
|
112
105
|
- test/bug.rb
|
106
|
+
- test/bug2.rb
|
113
107
|
- test/files.rb
|
114
108
|
- test/helper.rb
|
109
|
+
- test/io.rb
|
115
110
|
- test/isolated/shared.rb
|
116
111
|
- test/isolated/test_mimic_after.rb
|
117
112
|
- test/isolated/test_mimic_alone.rb
|
@@ -120,17 +115,15 @@ files:
|
|
120
115
|
- test/isolated/test_mimic_rails_after.rb
|
121
116
|
- test/isolated/test_mimic_rails_before.rb
|
122
117
|
- test/perf.rb
|
123
|
-
- test/perf1.rb
|
124
|
-
- test/perf2.rb
|
125
118
|
- test/perf_compat.rb
|
126
119
|
- test/perf_fast.rb
|
127
120
|
- test/perf_file.rb
|
128
|
-
- test/perf_obj_old.rb
|
129
121
|
- test/perf_object.rb
|
130
122
|
- test/perf_saj.rb
|
131
123
|
- test/perf_scp.rb
|
132
124
|
- test/perf_simple.rb
|
133
125
|
- test/perf_strict.rb
|
126
|
+
- test/sample.rb
|
134
127
|
- test/sample/change.rb
|
135
128
|
- test/sample/dir.rb
|
136
129
|
- test/sample/doc.rb
|
@@ -143,8 +136,8 @@ files:
|
|
143
136
|
- test/sample/rect.rb
|
144
137
|
- test/sample/shape.rb
|
145
138
|
- test/sample/text.rb
|
146
|
-
- test/sample.rb
|
147
139
|
- test/sample_json.rb
|
140
|
+
- test/struct.rb
|
148
141
|
- test/test_compat.rb
|
149
142
|
- test/test_debian.rb
|
150
143
|
- test/test_fast.rb
|
@@ -156,43 +149,35 @@ files:
|
|
156
149
|
- test/test_strict.rb
|
157
150
|
- test/test_various.rb
|
158
151
|
- test/test_writer.rb
|
159
|
-
-
|
160
|
-
-
|
152
|
+
- test/write_timebars.rb
|
153
|
+
- test/zip.rb
|
161
154
|
homepage: http://www.ohler.com/oj
|
162
|
-
licenses:
|
155
|
+
licenses:
|
163
156
|
- MIT
|
164
157
|
- GPL-3.0
|
158
|
+
metadata: {}
|
165
159
|
post_install_message:
|
166
|
-
rdoc_options:
|
167
|
-
- --main
|
160
|
+
rdoc_options:
|
161
|
+
- "--main"
|
168
162
|
- README.md
|
169
|
-
require_paths:
|
163
|
+
require_paths:
|
170
164
|
- lib
|
171
165
|
- ext
|
172
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
-
|
174
|
-
requirements:
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
175
168
|
- - ">="
|
176
|
-
- !ruby/object:Gem::Version
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
version: "0"
|
181
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
-
none: false
|
183
|
-
requirements:
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
184
173
|
- - ">="
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
|
187
|
-
segments:
|
188
|
-
- 0
|
189
|
-
version: "0"
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
190
176
|
requirements: []
|
191
|
-
|
192
177
|
rubyforge_project: oj
|
193
|
-
rubygems_version:
|
178
|
+
rubygems_version: 2.2.2
|
194
179
|
signing_key:
|
195
|
-
specification_version:
|
180
|
+
specification_version: 4
|
196
181
|
summary: A fast JSON parser and serializer.
|
197
182
|
test_files: []
|
198
|
-
|
183
|
+
has_rdoc: true
|
data/test/perf1.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -wW1
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
$: << File.join(File.dirname(__FILE__), "../lib")
|
5
|
-
$: << File.join(File.dirname(__FILE__), "../ext")
|
6
|
-
|
7
|
-
#require 'test/unit'
|
8
|
-
require 'optparse'
|
9
|
-
require 'oj'
|
10
|
-
require 'ox'
|
11
|
-
|
12
|
-
$indent = 2
|
13
|
-
|
14
|
-
opts = OptionParser.new
|
15
|
-
opts.on("-h", "--help", "Show this display") { puts opts; Process.exit!(0) }
|
16
|
-
files = opts.parse(ARGV)
|
17
|
-
|
18
|
-
iter = 100000
|
19
|
-
s = %{
|
20
|
-
{ "class": "Foo::Bar",
|
21
|
-
"attr1": [ true, [false, [12345, null], 3.967, ["something", false], null]],
|
22
|
-
"attr2": { "one": 1 }
|
23
|
-
}
|
24
|
-
}
|
25
|
-
#s = File.read('sample.json')
|
26
|
-
|
27
|
-
Oj.default_options = { :indent => 0 }
|
28
|
-
|
29
|
-
obj = Oj.load(s)
|
30
|
-
xml = Ox.dump(obj, :indent => 0)
|
31
|
-
|
32
|
-
puts xml
|
33
|
-
|
34
|
-
start = Time.now
|
35
|
-
iter.times do
|
36
|
-
Oj.load(s)
|
37
|
-
end
|
38
|
-
dt = Time.now - start
|
39
|
-
puts "%d Oj.load()s in %0.3f seconds or %0.1f loads/msec" % [iter, dt, iter/dt/1000.0]
|
40
|
-
|
41
|
-
start = Time.now
|
42
|
-
iter.times do
|
43
|
-
Ox.load(xml)
|
44
|
-
end
|
45
|
-
dt = Time.now - start
|
46
|
-
puts "%d Ox.load()s in %0.3f seconds or %0.1f loads/msec" % [iter, dt, iter/dt/1000.0]
|
47
|
-
|
48
|
-
puts
|
49
|
-
|
50
|
-
start = Time.now
|
51
|
-
iter.times do
|
52
|
-
Oj.dump(obj)
|
53
|
-
end
|
54
|
-
dt = Time.now - start
|
55
|
-
puts "%d Oj.dump()s in %0.3f seconds or %0.1f dumps/msec" % [iter, dt, iter/dt/1000.0]
|
56
|
-
|
57
|
-
start = Time.now
|
58
|
-
iter.times do
|
59
|
-
Ox.dump(obj)
|
60
|
-
end
|
61
|
-
dt = Time.now - start
|
62
|
-
puts "%d Ox.dump()s in %0.3f seconds or %0.1f dumps/msec" % [iter, dt, iter/dt/1000.0]
|
63
|
-
|
64
|
-
puts
|
data/test/perf2.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -wW1
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
$: << File.join(File.dirname(__FILE__), "../lib")
|
5
|
-
$: << File.join(File.dirname(__FILE__), "../ext")
|
6
|
-
|
7
|
-
#require 'test/unit'
|
8
|
-
require 'optparse'
|
9
|
-
require 'yajl'
|
10
|
-
require 'oj'
|
11
|
-
|
12
|
-
$indent = 2
|
13
|
-
|
14
|
-
opts = OptionParser.new
|
15
|
-
opts.on("-h", "--help", "Show this display") { puts opts; Process.exit!(0) }
|
16
|
-
files = opts.parse(ARGV)
|
17
|
-
|
18
|
-
class Foo
|
19
|
-
def initialize()
|
20
|
-
@x = true
|
21
|
-
@y = 58
|
22
|
-
end
|
23
|
-
def to_json()
|
24
|
-
%{{"x":#{@x},"y":#{@y}}}
|
25
|
-
end
|
26
|
-
def to_hash()
|
27
|
-
{ 'x' => @x, 'y' => @y }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
iter = 100000
|
32
|
-
s = %{
|
33
|
-
{ "class": "Foo::Bar",
|
34
|
-
"attr1": [ true, [false, [12345, null], 3.967, ["something", false], null]],
|
35
|
-
"attr2": { "one": 1 }
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
obj = Oj.load(s)
|
40
|
-
obj["foo"] = Foo.new()
|
41
|
-
|
42
|
-
Oj.default_options = { :indent => 0, :effort => :internal }
|
43
|
-
|
44
|
-
puts
|
45
|
-
|
46
|
-
start = Time.now
|
47
|
-
iter.times do
|
48
|
-
Oj.load(s)
|
49
|
-
end
|
50
|
-
dt = Time.now - start
|
51
|
-
puts "%d Oj.load()s in %0.3f seconds or %0.1f loads/msec" % [iter, dt, iter/dt/1000.0]
|
52
|
-
|
53
|
-
start = Time.now
|
54
|
-
iter.times do
|
55
|
-
Yajl::Parser.parse(s)
|
56
|
-
end
|
57
|
-
dt = Time.now - start
|
58
|
-
puts "%d Yajl::Parser.parse()s in %0.3f seconds or %0.1f parses/msec" % [iter, dt, iter/dt/1000.0]
|
59
|
-
|
60
|
-
puts
|
61
|
-
|
62
|
-
start = Time.now
|
63
|
-
iter.times do
|
64
|
-
Oj.dump(obj)
|
65
|
-
end
|
66
|
-
dt = Time.now - start
|
67
|
-
puts "%d Oj.dump()s in %0.3f seconds or %0.1f dumps/msec" % [iter, dt, iter/dt/1000.0]
|
68
|
-
|
69
|
-
start = Time.now
|
70
|
-
iter.times do
|
71
|
-
Yajl::Encoder.encode(obj)
|
72
|
-
end
|
73
|
-
dt = Time.now - start
|
74
|
-
puts "%d Yajl::Encoder.encode()s in %0.3f seconds or %0.1f encodes/msec" % [iter, dt, iter/dt/1000.0]
|
75
|
-
|
76
|
-
puts
|