diff options
author | Jean Boussier <[email protected]> | 2025-04-15 13:43:23 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2025-04-15 16:48:22 +0900 |
commit | 77a52787a6321ee8964c1a6ccc5547abc4a08caf (patch) | |
tree | 5ae3148f8d7f1a6dddfcb99467a14cf1331aa8da /ext/json | |
parent | 26a9ccbf83957877355ef5eb3993dc28e07e4278 (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.rb | 15 |
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 |