json 1.8.1-java → 1.8.2-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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 051bb7dee977c246c7207fc1ff0e53ab7d24bf9b
4
- data.tar.gz: 888d7fc06132dca085189a158c53fe0c5d8ecfd6
3
+ metadata.gz: dedec927fc4d0b7e2a25506886539ab45d983fe2
4
+ data.tar.gz: aa0948094df5bf9c40fbcd3a7a5615b475d46b1d
5
5
  SHA512:
6
- metadata.gz: ad56c1380688ad7a15ffba65e804477bf44151eb35bc45a2a408741e8a1e1e9bbeb829b294837adaa9481a0fd600e69f90c789d9200f2e72154f3bd88f7f08cf
7
- data.tar.gz: c113d7eb559056851fa7cd3dfe4ee642d619117199491366ce6099093f40f3802b9d8d4120f7f5c618233d0124e7945884359246be7c2c72164f06efcb105535
6
+ metadata.gz: 590bc46bfdaf1b8c365265dacf1e5fc81cff2a91fb0bfa2da845555d9264d3bd164b19e8e1a1c066cda359ddacb8cfdebe562f73861183e155f1ef8c0695d2b5
7
+ data.tar.gz: 8b1fb13edd5ee877fc09c17b4ab78a41d303918cc473b04fad606fbbbf3197dcfa37a918d27c2d4632b4ee1209d1355d87ca668d3f5e317a57b35c451c7f5b2b
@@ -4,10 +4,15 @@ end
4
4
  defined?(::Complex) or require 'complex'
5
5
 
6
6
  class Complex
7
+
8
+ # Deserializes JSON string by converting Real value <tt>r</tt>, imaginary
9
+ # value <tt>i</tt>, to a Complex object.
7
10
  def self.json_create(object)
8
11
  Complex(object['r'], object['i'])
9
12
  end
10
13
 
14
+ # Returns a hash, that will be turned into a JSON object and represent this
15
+ # object.
11
16
  def as_json(*)
12
17
  {
13
18
  JSON.create_id => self.class.name,
@@ -16,7 +21,8 @@ class Complex
16
21
  }
17
22
  end
18
23
 
24
+ # Stores class name (Complex) along with real value <tt>r</tt> and imaginary value <tt>i</tt> as JSON string
19
25
  def to_json(*)
20
26
  as_json.to_json
21
27
  end
22
- end
28
+ end
@@ -4,10 +4,14 @@ end
4
4
  defined?(::Rational) or require 'rational'
5
5
 
6
6
  class Rational
7
+ # Deserializes JSON string by converting numerator value <tt>n</tt>,
8
+ # denominator value <tt>d</tt>, to a Rational object.
7
9
  def self.json_create(object)
8
10
  Rational(object['n'], object['d'])
9
11
  end
10
12
 
13
+ # Returns a hash, that will be turned into a JSON object and represent this
14
+ # object.
11
15
  def as_json(*)
12
16
  {
13
17
  JSON.create_id => self.class.name,
@@ -16,6 +20,7 @@ class Rational
16
20
  }
17
21
  end
18
22
 
23
+ # Stores class name (Rational) along with numerator value <tt>n</tt> and denominator value <tt>d</tt> as JSON string
19
24
  def to_json(*)
20
25
  as_json.to_json
21
26
  end
@@ -10,7 +10,7 @@ class Time
10
10
  if usec = object.delete('u') # used to be tv_usec -> tv_nsec
11
11
  object['n'] = usec * 1000
12
12
  end
13
- if instance_methods.include?(:tv_nsec)
13
+ if method_defined?(:tv_nsec)
14
14
  at(object['s'], Rational(object['n'], 1000))
15
15
  else
16
16
  at(object['s'], object['n'] / 1000)
@@ -148,7 +148,7 @@ module JSON
148
148
  # the default.
149
149
  # * *create_additions*: If set to false, the Parser doesn't create
150
150
  # additions even if a matching class and create_id was found. This option
151
- # defaults to true.
151
+ # defaults to false.
152
152
  # * *object_class*: Defaults to Hash
153
153
  # * *array_class*: Defaults to Array
154
154
  def parse(source, opts = {})
@@ -169,7 +169,7 @@ module JSON
169
169
  # to true.
170
170
  # * *create_additions*: If set to false, the Parser doesn't create
171
171
  # additions even if a matching class and create_id was found. This option
172
- # defaults to true.
172
+ # defaults to false.
173
173
  def parse!(source, opts = {})
174
174
  opts = {
175
175
  :max_nesting => false,
@@ -390,7 +390,7 @@ module JSON
390
390
  end
391
391
  end
392
392
  opts = JSON.dump_default_options
393
- limit and opts.update(:max_nesting => limit)
393
+ opts = opts.merge(:max_nesting => limit) if limit
394
394
  result = generate(obj, opts)
395
395
  if anIO
396
396
  anIO.write result
@@ -411,7 +411,7 @@ module JSON
411
411
  string
412
412
  end
413
413
 
414
- # Shortuct for iconv.
414
+ # Shortcut for iconv.
415
415
  if ::String.method_defined?(:encode)
416
416
  # Encodes string using Ruby's _String.encode_
417
417
  def self.iconv(to, from, string)
@@ -448,7 +448,7 @@ module ::Kernel
448
448
  nil
449
449
  end
450
450
 
451
- # Ouputs _objs_ to STDOUT as JSON strings in a pretty format, with
451
+ # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
452
452
  # indentation and over many lines.
453
453
  def jj(*objs)
454
454
  objs.each do |obj|
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.8.1'
3
+ VERSION = '1.8.2'
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:
@@ -491,6 +491,8 @@ EOT
491
491
  assert_equal @hash, JSON.load(stringio)
492
492
  assert_equal nil, JSON.load(nil)
493
493
  assert_equal nil, JSON.load('')
494
+ ensure
495
+ tempfile.close!
494
496
  end
495
497
 
496
498
  def test_load_with_options
@@ -515,6 +517,12 @@ EOT
515
517
  assert_equal too_deep, output.string
516
518
  end
517
519
 
520
+ def test_dump_should_modify_defaults
521
+ max_nesting = JSON.dump_default_options[:max_nesting]
522
+ JSON.dump([], StringIO.new, 10)
523
+ assert_equal max_nesting, JSON.dump_default_options[:max_nesting]
524
+ end
525
+
518
526
  def test_big_integers
519
527
  json1 = JSON([orig = (1 << 31) - 1])
520
528
  assert_equal orig, JSON[json1][0]
@@ -73,6 +73,19 @@ EOT
73
73
  assert_equal '666', pretty_generate(666, :quirks_mode => true)
74
74
  end
75
75
 
76
+ def test_generate_custom
77
+ state = State.new(:space_before => " ", :space => " ", :indent => "<i>", :object_nl => "\n", :array_nl => "<a_nl>")
78
+ json = generate({1=>{2=>3,4=>[5,6]}}, state)
79
+ assert_equal(<<'EOT'.chomp, json)
80
+ {
81
+ <i>"1" : {
82
+ <i><i>"2" : 3,
83
+ <i><i>"4" : [<a_nl><i><i><i>5,<a_nl><i><i><i>6<a_nl><i><i>]
84
+ <i>}
85
+ }
86
+ EOT
87
+ end
88
+
76
89
  def test_fast_generate
77
90
  json = fast_generate(@hash)
78
91
  assert_equal(JSON.parse(@json2), JSON.parse(json))
@@ -215,16 +228,18 @@ EOT
215
228
  end
216
229
 
217
230
  def test_gc
218
- bignum_too_long_to_embed_as_string = 1234567890123456789012345
219
- expect = bignum_too_long_to_embed_as_string.to_s
220
- stress, GC.stress = GC.stress, true
231
+ if respond_to?(:assert_in_out_err)
232
+ assert_in_out_err(%w[-rjson --disable-gems], <<-EOS, [], [])
233
+ bignum_too_long_to_embed_as_string = 1234567890123456789012345
234
+ expect = bignum_too_long_to_embed_as_string.to_s
235
+ GC.stress = true
221
236
 
222
- 10.times do |i|
223
- tmp = bignum_too_long_to_embed_as_string.to_json
224
- assert_equal expect, tmp
237
+ 10.times do |i|
238
+ tmp = bignum_too_long_to_embed_as_string.to_json
239
+ raise "'\#{expect}' is expected, but '\#{tmp}'" unless tmp == expect
240
+ end
241
+ EOS
225
242
  end
226
- ensure
227
- GC.stress = stress
228
243
  end if GC.respond_to?(:stress=)
229
244
 
230
245
  def test_configure_using_configure_and_merge
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: java
6
6
  authors:
7
7
  - Daniel Luz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A JSON implementation as a JRuby extension.
14
14
  email: dev+ruby@mernen.com