summaryrefslogtreecommitdiff
path: root/test/json/test_json_generic_object.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/json/test_json_generic_object.rb')
-rw-r--r--test/json/test_json_generic_object.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/json/test_json_generic_object.rb b/test/json/test_json_generic_object.rb
index 77ef22e6ae..c43c7762be 100644
--- a/test/json/test_json_generic_object.rb
+++ b/test/json/test_json_generic_object.rb
@@ -49,6 +49,21 @@ class TestJSONGenericObject < Test::Unit::TestCase
assert_equal true, GenericObject.from_hash(true)
end
+ def test_json_generic_object_load
+ empty = JSON::GenericObject.load(nil)
+ assert_kind_of JSON::GenericObject, empty
+ simple_json = '{"json_class":"JSON::GenericObject","hello":"world"}'
+ simple = JSON::GenericObject.load(simple_json)
+ assert_kind_of JSON::GenericObject, simple
+ assert_equal "world", simple.hello
+ converting = JSON::GenericObject.load('{ "hello": "world" }')
+ assert_kind_of JSON::GenericObject, converting
+ assert_equal "world", converting.hello
+
+ json = JSON::GenericObject.dump(JSON::GenericObject[:hello => 'world'])
+ assert_equal JSON(json), JSON('{"json_class":"JSON::GenericObject","hello":"world"}')
+ end
+
private
def switch_json_creatable