json_pure 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +8 -0
- data/Gemfile +3 -5
- data/Rakefile +34 -5
- data/VERSION +1 -1
- data/bin/prettify_json.rb +12 -39
- data/ext/json/ext/generator/generator.c +62 -22
- data/ext/json/ext/generator/generator.h +5 -2
- data/ext/json/ext/parser/parser.c +496 -285
- data/ext/json/ext/parser/parser.h +5 -1
- data/ext/json/ext/parser/parser.rl +155 -81
- data/java/src/json/ext/Generator.java +5 -5
- data/java/src/json/ext/GeneratorMethods.java +8 -7
- data/java/src/json/ext/GeneratorService.java +5 -4
- data/java/src/json/ext/GeneratorState.java +44 -16
- data/java/src/json/ext/OptionsReader.java +3 -3
- data/java/src/json/ext/Parser.java +399 -117
- data/java/src/json/ext/Parser.rl +118 -38
- data/java/src/json/ext/ParserService.java +4 -3
- data/java/src/json/ext/RuntimeInfo.java +23 -21
- data/java/src/json/ext/Utils.java +2 -2
- data/json.gemspec +17 -17
- data/json_pure.gemspec +22 -16
- data/lib/json.rb +7 -7
- data/lib/json/add/complex.rb +22 -0
- data/lib/json/add/core.rb +9 -9
- data/lib/json/add/rational.rb +22 -0
- data/lib/json/common.rb +50 -38
- data/lib/json/editor.rb +16 -16
- data/lib/json/ext.rb +2 -15
- data/lib/json/pure/generator.rb +18 -3
- data/lib/json/pure/parser.rb +92 -58
- data/lib/json/version.rb +1 -1
- data/tests/test_json.rb +52 -1
- data/tests/test_json_addition.rb +9 -2
- data/tests/test_json_generate.rb +34 -1
- data/tools/fuzz.rb +1 -1
- metadata +70 -51
- data/lib/json/add/rails.rb +0 -8
data/tests/test_json_addition.rb
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require 'test/unit'
|
5
5
|
require File.join(File.dirname(__FILE__), 'setup_variant')
|
6
|
-
|
6
|
+
require 'json/add/core'
|
7
|
+
require 'json/add/complex'
|
8
|
+
require 'json/add/rational'
|
7
9
|
require 'date'
|
8
10
|
|
9
11
|
class TC_JSONAddition < Test::Unit::TestCase
|
@@ -19,7 +21,7 @@ class TC_JSONAddition < Test::Unit::TestCase
|
|
19
21
|
def ==(other)
|
20
22
|
a == other.a
|
21
23
|
end
|
22
|
-
|
24
|
+
|
23
25
|
def self.json_create(object)
|
24
26
|
new(*object['args'])
|
25
27
|
end
|
@@ -164,4 +166,9 @@ class TC_JSONAddition < Test::Unit::TestCase
|
|
164
166
|
d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(12,24))
|
165
167
|
assert_equal d, JSON.parse(d.to_json)
|
166
168
|
end
|
169
|
+
|
170
|
+
def test_rational_complex
|
171
|
+
assert_equal Rational(2, 9), JSON(JSON(Rational(2, 9)))
|
172
|
+
assert_equal Complex(2, 9), JSON(JSON(Complex(2, 9)))
|
173
|
+
end
|
167
174
|
end
|
data/tests/test_json_generate.rb
CHANGED
@@ -50,6 +50,7 @@ EOT
|
|
50
50
|
parsed_json = parse(json)
|
51
51
|
assert_equal({"1"=>2}, parsed_json)
|
52
52
|
assert_raise(GeneratorError) { generate(666) }
|
53
|
+
assert_equal '666', generate(666, :quirks_mode => true)
|
53
54
|
end
|
54
55
|
|
55
56
|
def test_generate_pretty
|
@@ -67,6 +68,7 @@ EOT
|
|
67
68
|
parsed_json = parse(json)
|
68
69
|
assert_equal({"1"=>2}, parsed_json)
|
69
70
|
assert_raise(GeneratorError) { pretty_generate(666) }
|
71
|
+
assert_equal '666', pretty_generate(666, :quirks_mode => true)
|
70
72
|
end
|
71
73
|
|
72
74
|
def test_fast_generate
|
@@ -79,9 +81,24 @@ EOT
|
|
79
81
|
parsed_json = parse(json)
|
80
82
|
assert_equal({"1"=>2}, parsed_json)
|
81
83
|
assert_raise(GeneratorError) { fast_generate(666) }
|
84
|
+
assert_equal '666', fast_generate(666, :quirks_mode => true)
|
82
85
|
end
|
83
86
|
|
84
|
-
|
87
|
+
def test_own_state
|
88
|
+
state = State.new
|
89
|
+
json = generate(@hash, state)
|
90
|
+
assert_equal(JSON.parse(@json2), JSON.parse(json))
|
91
|
+
parsed_json = parse(json)
|
92
|
+
assert_equal(@hash, parsed_json)
|
93
|
+
json = generate({1=>2}, state)
|
94
|
+
assert_equal('{"1":2}', json)
|
95
|
+
parsed_json = parse(json)
|
96
|
+
assert_equal({"1"=>2}, parsed_json)
|
97
|
+
assert_raise(GeneratorError) { generate(666, state) }
|
98
|
+
state.quirks_mode = true
|
99
|
+
assert state.quirks_mode?
|
100
|
+
assert_equal '666', generate(666, state)
|
101
|
+
end
|
85
102
|
|
86
103
|
def test_states
|
87
104
|
json = generate({1=>2}, nil)
|
@@ -107,6 +124,7 @@ EOT
|
|
107
124
|
:allow_nan => false,
|
108
125
|
:array_nl => "\n",
|
109
126
|
:ascii_only => false,
|
127
|
+
:quirks_mode => false,
|
110
128
|
:depth => 0,
|
111
129
|
:indent => " ",
|
112
130
|
:max_nesting => 19,
|
@@ -122,6 +140,7 @@ EOT
|
|
122
140
|
:allow_nan => false,
|
123
141
|
:array_nl => "",
|
124
142
|
:ascii_only => false,
|
143
|
+
:quirks_mode => false,
|
125
144
|
:depth => 0,
|
126
145
|
:indent => "",
|
127
146
|
:max_nesting => 19,
|
@@ -137,6 +156,7 @@ EOT
|
|
137
156
|
:allow_nan => false,
|
138
157
|
:array_nl => "",
|
139
158
|
:ascii_only => false,
|
159
|
+
:quirks_mode => false,
|
140
160
|
:depth => 0,
|
141
161
|
:indent => "",
|
142
162
|
:max_nesting => 0,
|
@@ -177,4 +197,17 @@ EOT
|
|
177
197
|
assert_raises(JSON::NestingError) { ary.to_json(s) }
|
178
198
|
assert_equal 19, s.depth
|
179
199
|
end
|
200
|
+
|
201
|
+
def test_gc
|
202
|
+
bignum_too_long_to_embed_as_string = 1234567890123456789012345
|
203
|
+
expect = bignum_too_long_to_embed_as_string.to_s
|
204
|
+
stress, GC.stress = GC.stress, true
|
205
|
+
|
206
|
+
10.times do |i|
|
207
|
+
tmp = bignum_too_long_to_embed_as_string.to_json
|
208
|
+
assert_equal expect, tmp
|
209
|
+
end
|
210
|
+
ensure
|
211
|
+
GC.stress = stress
|
212
|
+
end if GC.respond_to?(:stress=)
|
180
213
|
end
|
data/tools/fuzz.rb
CHANGED
metadata
CHANGED
@@ -1,60 +1,80 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_pure
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.5.4
|
4
5
|
prerelease:
|
5
|
-
version: 1.5.3
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Florian Frank
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-08-31 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: permutation
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2151824220 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
24
22
|
type: :development
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: bullshit
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: *2151824220
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bullshit
|
27
|
+
requirement: &2151823400 !ruby/object:Gem::Requirement
|
30
28
|
none: false
|
31
|
-
requirements:
|
32
|
-
- -
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version:
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
35
33
|
type: :development
|
36
|
-
|
37
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2151823400
|
36
|
+
- !ruby/object:Gem::Dependency
|
38
37
|
name: sdoc
|
38
|
+
requirement: &2151822900 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
39
45
|
prerelease: false
|
40
|
-
|
46
|
+
version_requirements: *2151822900
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &2151821780 !ruby/object:Gem::Requirement
|
41
50
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version:
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.2
|
46
55
|
type: :development
|
47
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2151821780
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: spruz
|
60
|
+
requirement: &2151820960 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.2.8
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2151820960
|
48
69
|
description: This is a JSON implementation in pure Ruby.
|
49
70
|
email: flori@ping.de
|
50
|
-
executables:
|
71
|
+
executables:
|
51
72
|
- edit_json.rb
|
52
73
|
- prettify_json.rb
|
53
74
|
extensions: []
|
54
|
-
|
55
|
-
extra_rdoc_files:
|
75
|
+
extra_rdoc_files:
|
56
76
|
- README.rdoc
|
57
|
-
files:
|
77
|
+
files:
|
58
78
|
- tests/test_json_string_matching.rb
|
59
79
|
- tests/test_json_fixtures.rb
|
60
80
|
- tests/setup_variant.rb
|
@@ -138,8 +158,9 @@ files:
|
|
138
158
|
- lib/json/TrueClass.xpm
|
139
159
|
- lib/json/version.rb
|
140
160
|
- lib/json/Array.xpm
|
161
|
+
- lib/json/add/complex.rb
|
162
|
+
- lib/json/add/rational.rb
|
141
163
|
- lib/json/add/core.rb
|
142
|
-
- lib/json/add/rails.rb
|
143
164
|
- lib/json/common.rb
|
144
165
|
- lib/json/pure/generator.rb
|
145
166
|
- lib/json/pure/parser.rb
|
@@ -202,35 +223,33 @@ files:
|
|
202
223
|
- ./tests/test_json.rb
|
203
224
|
homepage: http://flori.github.com/json
|
204
225
|
licenses: []
|
205
|
-
|
206
226
|
post_install_message:
|
207
|
-
rdoc_options:
|
227
|
+
rdoc_options:
|
208
228
|
- --title
|
209
229
|
- JSON implemention for ruby
|
210
230
|
- --main
|
211
231
|
- README.rdoc
|
212
|
-
require_paths:
|
232
|
+
require_paths:
|
213
233
|
- lib
|
214
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
234
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
215
235
|
none: false
|
216
|
-
requirements:
|
217
|
-
- -
|
218
|
-
- !ruby/object:Gem::Version
|
219
|
-
version:
|
220
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
|
+
requirements:
|
237
|
+
- - ! '>='
|
238
|
+
- !ruby/object:Gem::Version
|
239
|
+
version: '0'
|
240
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
241
|
none: false
|
222
|
-
requirements:
|
223
|
-
- -
|
224
|
-
- !ruby/object:Gem::Version
|
225
|
-
version:
|
242
|
+
requirements:
|
243
|
+
- - ! '>='
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: '0'
|
226
246
|
requirements: []
|
227
|
-
|
228
247
|
rubyforge_project: json
|
229
|
-
rubygems_version: 1.8.
|
248
|
+
rubygems_version: 1.8.10
|
230
249
|
signing_key:
|
231
250
|
specification_version: 3
|
232
251
|
summary: JSON Implementation for Ruby
|
233
|
-
test_files:
|
252
|
+
test_files:
|
234
253
|
- ./tests/test_json_string_matching.rb
|
235
254
|
- ./tests/test_json_fixtures.rb
|
236
255
|
- ./tests/test_json_unicode.rb
|
data/lib/json/add/rails.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
# This file used to implementations of rails custom objects for
|
2
|
-
# serialisation/deserialisation and is obsoleted now.
|
3
|
-
|
4
|
-
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
|
5
|
-
require 'json'
|
6
|
-
end
|
7
|
-
|
8
|
-
$DEBUG and warn "required json/add/rails which is obsolete now!"
|