diff options
author | Ryan Davis <ryand-ruby@zenspider.com> | 2019-11-22 14:53:04 -0800 |
---|---|---|
committer | Ryan Davis <ryand-ruby@zenspider.com> | 2019-11-27 14:54:39 -0800 |
commit | 19da336333e63dc9dde7baea47b179e162b7568e (patch) | |
tree | ce10de9e526ed1397bd8cd8b71f32b42eec27e19 /lib | |
parent | 8d8e1aa70297d55034e3f6a4ce2f32300294b2a4 (diff) | |
download | json-19da336333e63dc9dde7baea47b179e162b7568e.tar.gz |
Minor cleanup for ruby 2.7 warnings and failures.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/json/common.rb | 5 | ||||
-rw-r--r-- | lib/json/pure/parser.rb | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb index 7cc8529..05da9d0 100644 --- a/lib/json/common.rb +++ b/lib/json/common.rb @@ -153,7 +153,8 @@ module JSON # * *object_class*: Defaults to Hash # * *array_class*: Defaults to Array def parse(source, opts = {}) - Parser.new(source, opts).parse + opts ||= {} + Parser.new(source, **opts).parse end # Parse the JSON document _source_ into a Ruby data structure and return it. @@ -176,7 +177,7 @@ module JSON :max_nesting => false, :allow_nan => true }.merge(opts) - Parser.new(source, opts).parse + Parser.new(source, **opts).parse end # Generate a JSON document from the Ruby data structure _obj_ and return diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb index 3a6343b..5340296 100644 --- a/lib/json/pure/parser.rb +++ b/lib/json/pure/parser.rb @@ -197,7 +197,15 @@ module JSON def parse_value case when scan(FLOAT) - @decimal_class && @decimal_class.new(self[1]) || Float(self[1]) + if @decimal_class then + if @decimal_class == BigDecimal then + BigDecimal(self[1]) + else + @decimal_class.new(self[1]) || Float(self[1]) + end + else + Float(self[1]) + end when scan(INTEGER) Integer(self[1]) when scan(TRUE) |