aboutsummaryrefslogtreecommitdiffstats
path: root/ext/json/lib
diff options
context:
space:
mode:
Diffstat (limited to 'ext/json/lib')
-rw-r--r--ext/json/lib/json/add/range.rb2
-rw-r--r--ext/json/lib/json/common.rb10
-rw-r--r--ext/json/lib/json/generic_object.rb9
-rw-r--r--ext/json/lib/json/version.rb2
4 files changed, 14 insertions, 9 deletions
diff --git a/ext/json/lib/json/add/range.rb b/ext/json/lib/json/add/range.rb
index d2a5b335e0..e61e553cdb 100644
--- a/ext/json/lib/json/add/range.rb
+++ b/ext/json/lib/json/add/range.rb
@@ -16,7 +16,7 @@ class Range
def as_json(*)
{
JSON.create_id => self.class.name,
- 'a' => [ first, self.end, exclude_end? ]
+ 'a' => [ first, last, exclude_end? ]
}
end
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index a547679962..e24f637f61 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -179,10 +179,9 @@ module JSON
end
# Generate a JSON document from the Ruby data structure _obj_ and return
- # it. _state_ is
- # * a JSON::State object,
+ # it. _state_ is * a JSON::State object,
# * or a Hash like object (responding to to_hash),
- # * or an object convertible into a hash by a to_h method,
+ # * an object convertible into a hash by a to_h method,
# that is used as or to configure a State object.
#
# It defaults to a state object, that creates the shortest possible JSON text
@@ -413,10 +412,7 @@ module JSON
end
# Shortuct for iconv.
- if ::String.method_defined?(:encode) &&
- # XXX Rubinius doesn't support ruby 1.9 encoding yet
- defined?(RUBY_ENGINE) && RUBY_ENGINE != 'rbx'
- then
+ if ::String.method_defined?(:encode)
# Encodes string using Ruby's _String.encode_
def self.iconv(to, from, string)
string.encode(to, from)
diff --git a/ext/json/lib/json/generic_object.rb b/ext/json/lib/json/generic_object.rb
index 8b1074c941..8b8fd53bef 100644
--- a/ext/json/lib/json/generic_object.rb
+++ b/ext/json/lib/json/generic_object.rb
@@ -31,6 +31,15 @@ module JSON
object
end
end
+
+ def load(source, proc = nil, opts = {})
+ result = ::JSON.load(source, proc, opts.merge(:object_class => self))
+ result.nil? ? new : result
+ end
+
+ def dump(obj, *args)
+ ::JSON.dump(obj, *args)
+ end
end
self.json_creatable = false
diff --git a/ext/json/lib/json/version.rb b/ext/json/lib/json/version.rb
index 1de3d696f2..47cdcd607c 100644
--- a/ext/json/lib/json/version.rb
+++ b/ext/json/lib/json/version.rb
@@ -1,6 +1,6 @@
module JSON
# JSON version
- VERSION = '1.7.7'
+ VERSION = '1.8.1'
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: