json 1.6.3-java → 1.6.4-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of json might be problematic. Click here for more details.

Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.6.3'
3
+ VERSION = '1.6.4'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -5,6 +5,7 @@ require 'test/unit'
5
5
  require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
  require 'stringio'
7
7
  require 'tempfile'
8
+ require 'ostruct'
8
9
 
9
10
  unless Array.method_defined?(:permutation)
10
11
  begin
@@ -218,13 +219,41 @@ class TC_JSON < Test::Unit::TestCase
218
219
  end
219
220
  end
220
221
 
221
- def test_parse_array_custom_class
222
+ class SubArrayWrapper
223
+ def initialize
224
+ @data = []
225
+ end
226
+
227
+ attr_reader :data
228
+
229
+ def [](index)
230
+ @data[index]
231
+ end
232
+
233
+ def <<(value)
234
+ @data << value
235
+ @shifted = true
236
+ end
237
+
238
+ def shifted?
239
+ @shifted
240
+ end
241
+ end
242
+
243
+ def test_parse_array_custom_array_derived_class
222
244
  res = parse('[1,2]', :array_class => SubArray)
223
245
  assert_equal([1,2], res)
224
246
  assert_equal(SubArray, res.class)
225
247
  assert res.shifted?
226
248
  end
227
249
 
250
+ def test_parse_array_custom_non_array_derived_class
251
+ res = parse('[1,2]', :array_class => SubArrayWrapper)
252
+ assert_equal([1,2], res.data)
253
+ assert_equal(SubArrayWrapper, res.class)
254
+ assert res.shifted?
255
+ end
256
+
228
257
  def test_parse_object
229
258
  assert_equal({}, parse('{}'))
230
259
  assert_equal({}, parse(' { } '))
@@ -256,13 +285,35 @@ class TC_JSON < Test::Unit::TestCase
256
285
  end
257
286
  end
258
287
 
259
- def test_parse_object_custom_class
288
+ class SubOpenStruct < OpenStruct
289
+ def [](k)
290
+ __send__(k)
291
+ end
292
+
293
+ def []=(k, v)
294
+ @item_set = true
295
+ __send__("#{k}=", v)
296
+ end
297
+
298
+ def item_set?
299
+ @item_set
300
+ end
301
+ end
302
+
303
+ def test_parse_object_custom_hash_derived_class
260
304
  res = parse('{"foo":"bar"}', :object_class => SubHash)
261
305
  assert_equal({"foo" => "bar"}, res)
262
306
  assert_equal(SubHash, res.class)
263
307
  assert res.item_set?
264
308
  end
265
309
 
310
+ def test_parse_object_custom_non_hash_derived_class
311
+ res = parse('{"foo":"bar"}', :object_class => SubOpenStruct)
312
+ assert_equal "bar", res.foo
313
+ assert_equal(SubOpenStruct, res.class)
314
+ assert res.item_set?
315
+ end
316
+
266
317
  def test_generation_of_core_subclasses_with_new_to_json
267
318
  obj = SubHash2["foo" => SubHash2["bar" => true]]
268
319
  obj_json = JSON(obj)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.6.3
5
+ version: 1.6.4
6
6
  platform: java
7
7
  authors:
8
8
  - Daniel Luz
@@ -10,7 +10,8 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-12-01 00:00:00 Z
13
+ date: 2011-12-24 00:00:00 +01:00
14
+ default_executable:
14
15
  dependencies: []
15
16
 
16
17
  description: A JSON implementation as a JRuby extension.
@@ -83,6 +84,7 @@ files:
83
84
  - tests/fixtures/fail22.json
84
85
  - tests/fixtures/fail27.json
85
86
  - tests/fixtures/fail19.json
87
+ has_rdoc: true
86
88
  homepage: http://json-jruby.rubyforge.org/
87
89
  licenses: []
88
90
 
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  requirements: []
107
109
 
108
110
  rubyforge_project: json-jruby
109
- rubygems_version: 1.8.11
111
+ rubygems_version: 1.5.1
110
112
  signing_key:
111
113
  specification_version: 3
112
114
  summary: JSON implementation for JRuby