summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/json/pure/parser.rb6
-rw-r--r--lib/json/version.rb2
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb
index b907236..3a6343b 100644
--- a/lib/json/pure/parser.rb
+++ b/lib/json/pure/parser.rb
@@ -70,6 +70,9 @@ module JSON
# option defaults to false.
# * *object_class*: Defaults to Hash
# * *array_class*: Defaults to Array
+ # * *decimal_class*: Specifies which class to use instead of the default
+ # (Float) when parsing decimal numbers. This class must accept a single
+ # string argument in its constructor.
def initialize(source, opts = {})
opts ||= {}
source = convert_encoding source
@@ -94,6 +97,7 @@ module JSON
@create_id = @create_additions ? JSON.create_id : nil
@object_class = opts[:object_class] || Hash
@array_class = opts[:array_class] || Array
+ @decimal_class = opts[:decimal_class]
@match_string = opts[:match_string]
end
@@ -193,7 +197,7 @@ module JSON
def parse_value
case
when scan(FLOAT)
- Float(self[1])
+ @decimal_class && @decimal_class.new(self[1]) || Float(self[1])
when scan(INTEGER)
Integer(self[1])
when scan(TRUE)
diff --git a/lib/json/version.rb b/lib/json/version.rb
index 8997def..b65ed87 100644
--- a/lib/json/version.rb
+++ b/lib/json/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module JSON
# JSON version
- VERSION = '2.0.2'
+ VERSION = '2.1.0'
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: