summaryrefslogtreecommitdiff
path: root/ext/json
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-04-15 13:43:23 +0900
committerHiroshi SHIBATA <[email protected]>2025-04-15 16:48:22 +0900
commit77a52787a6321ee8964c1a6ccc5547abc4a08caf (patch)
tree5ae3148f8d7f1a6dddfcb99467a14cf1331aa8da /ext/json
parent26a9ccbf83957877355ef5eb3993dc28e07e4278 (diff)
[ruby/json] Cleanup Kernel#JSON
https://github.com/ruby/json/commit/573ebdca89
Diffstat (limited to 'ext/json')
-rw-r--r--ext/json/lib/json/common.rb15
1 files changed, 3 insertions, 12 deletions
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index 37427534e0..b5fbfcf05d 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -123,7 +123,7 @@ module JSON
# Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate):
# ruby = [0, 1, nil]
# JSON[ruby] # => '[0,1,null]'
- def [](object, opts = {})
+ def [](object, opts = nil)
if object.is_a?(String)
return JSON.parse(object, opts)
elsif object.respond_to?(:to_str)
@@ -1038,16 +1038,7 @@ module ::Kernel
#
# The _opts_ argument is passed through to generate/parse respectively. See
# generate and parse for their documentation.
- def JSON(object, *args)
- if object.is_a?(String)
- return JSON.parse(object, args.first)
- elsif object.respond_to?(:to_str)
- str = object.to_str
- if str.is_a?(String)
- return JSON.parse(object.to_str, args.first)
- end
- end
-
- JSON.generate(object, args.first)
+ def JSON(object, opts = nil)
+ JSON[object, opts]
end
end