diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-11-29 12:50:03 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-11-29 12:50:03 +0900 |
commit | bfe61e17f97d6a2e376c994319aa709e8625e33a (patch) | |
tree | 2a49df53cc0fd56b8ee72184a42eb82fe9d20219 /lib | |
parent | e5e9a7781831bc3acd48854cd860e92b53c568f0 (diff) | |
parent | 927c1672c6aaafb45d11e7ac8cad8f7c3a8fb0b6 (diff) | |
download | json-bfe61e17f97d6a2e376c994319aa709e8625e33a.tar.gz |
Merge branch 'zenspider/ruby-2.7' of https://github.com/zenspider/json into zenspider-zenspider/ruby-2.7
Diffstat (limited to 'lib')
-rw-r--r-- | lib/json/pure/generator.rb | 3 | ||||
-rw-r--r-- | lib/json/pure/parser.rb | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb index ccb6fe4..a1143f8 100644 --- a/lib/json/pure/generator.rb +++ b/lib/json/pure/generator.rb @@ -250,7 +250,8 @@ module JSON if respond_to?(name) __send__(name) else - instance_variable_get("@#{name}") + instance_variable_get("@#{name}") if + instance_variables.include?("@#{name}".to_sym) # avoid warning end end 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) |