json 2.0.4-java → 2.1.0-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: d0db7a736d440117cc169284329a8216abff741c
4
- data.tar.gz: e6d9b23ed0ea1bce5f817986228b0aeb37c20299
3
+ metadata.gz: 634b7c9d77f51f54770f912bce42e4a6765ad87f
4
+ data.tar.gz: 67189aeb4ed037c326096522f03d5455d875c5e0
5
5
  SHA512:
6
- metadata.gz: 41b6f438f4e8306df74bf7a7ff00921b1512600b91e862d480c27c7c2227a65bcafcc12f40e18f348d006a6dcfee9b2dc93534307b90c1b6f2e2e7dbdecbe8f7
7
- data.tar.gz: b53ad6c59238d6f52bd96165582df10309ade77010b76a18a8babe3b3a02b6712130058fa46bb51b88a815336ea343c8d9308ee94a0e9b5b5ec1b9b2b2a9975b
6
+ metadata.gz: 7f4402403159951b48a71ae16f990e5a273f89bd249d27d8fc1b965c2017de88480941e3d3f73bb068e5f4e7a91f05dcd46f077f3149c26acada386752e7d796
7
+ data.tar.gz: '082bde17c11b76f51ae1fd60df8dd72bdee08c31aae7495d436f1a12d0c2f5b29c028ac2e151921ae8cbe0a027f135a21dd703fea39243dfd5cdfb2667ba2fbd'
Binary file
Binary file
@@ -70,6 +70,9 @@ module JSON
70
70
  # option defaults to false.
71
71
  # * *object_class*: Defaults to Hash
72
72
  # * *array_class*: Defaults to Array
73
+ # * *decimal_class*: Specifies which class to use instead of the default
74
+ # (Float) when parsing decimal numbers. This class must accept a single
75
+ # string argument in its constructor.
73
76
  def initialize(source, opts = {})
74
77
  opts ||= {}
75
78
  source = convert_encoding source
@@ -94,6 +97,7 @@ module JSON
94
97
  @create_id = @create_additions ? JSON.create_id : nil
95
98
  @object_class = opts[:object_class] || Hash
96
99
  @array_class = opts[:array_class] || Array
100
+ @decimal_class = opts[:decimal_class]
97
101
  @match_string = opts[:match_string]
98
102
  end
99
103
 
@@ -193,7 +197,7 @@ module JSON
193
197
  def parse_value
194
198
  case
195
199
  when scan(FLOAT)
196
- Float(self[1])
200
+ @decimal_class && @decimal_class.new(self[1]) || Float(self[1])
197
201
  when scan(INTEGER)
198
202
  Integer(self[1])
199
203
  when scan(TRUE)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
  module JSON
3
3
  # JSON version
4
- VERSION = '2.0.4'
4
+ VERSION = '2.1.0'
5
5
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
6
6
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
7
7
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -79,8 +79,8 @@ class JSONEncodingTest < Test::Unit::TestCase
79
79
  json = '["\ud840\udc01"]'
80
80
  assert_equal json, generate(utf8, :ascii_only => true)
81
81
  assert_equal utf8, parse(json)
82
- assert_raises(JSON::ParserError) { parse('"\u"') }
83
- assert_raises(JSON::ParserError) { parse('"\ud800"') }
82
+ assert_raise(JSON::ParserError) { parse('"\u"') }
83
+ assert_raise(JSON::ParserError) { parse('"\ud800"') }
84
84
  end
85
85
 
86
86
  def test_chars
@@ -108,6 +108,11 @@ class JSONParserTest < Test::Unit::TestCase
108
108
  assert_equal -1.0/0, parse('-Infinity', :allow_nan => true)
109
109
  end
110
110
 
111
+ def test_parse_bigdecimals
112
+ assert_equal(BigDecimal, JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"].class)
113
+ assert_equal(BigDecimal.new("0.901234567890123456789E1"),JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"] )
114
+ end
115
+
111
116
  if Array.method_defined?(:permutation)
112
117
  def test_parse_more_complex_arrays
113
118
  a = [ nil, false, true, "foßbar", [ "n€st€d", true ], { "nested" => true, "n€ßt€ð2" => {} }]
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: 2.0.4
4
+ version: 2.1.0
5
5
  platform: java
6
6
  authors:
7
7
  - Daniel Luz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement