diff options
author | Jean Boussier <[email protected]> | 2025-03-27 10:16:10 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2025-03-28 12:44:53 +0900 |
commit | 26e55562ce449d407c95891c8d3258e15cc9b129 () | |
tree | 7e98f3be9b750f06d86ab6646405fea4388f1988 /ext/json/lib | |
parent | 2b9a9300ac4cb00824d59e59f6671a77cc003a1f (diff) |
[ruby/json] Cleanup JSON.pretty_generate
https://.com/ruby/json/commit/01c47a0555
Notes: Merged: https://.com/ruby/ruby/pull/13004
-rw-r--r-- | ext/json/lib/json/common.rb | 45 |
1 files changed, 23 insertions, 22 deletions
@@ -74,15 +74,6 @@ module JSON $VERBOSE = old end - def create_pretty_state - State.new( - :indent => ' ', - :space => ' ', - :object_nl => "\n", - :array_nl => "\n" - ) - end - # Returns the JSON generator module that is used by JSON. attr_reader :generator @@ -366,6 +357,14 @@ module JSON generate(obj, opts) end # :call-seq: # JSON.pretty_generate(obj, opts = nil) -> new_string # @@ -397,22 +396,24 @@ module JSON # } # def pretty_generate(obj, opts = nil) - if State === opts - state, opts = opts, nil - else - state = JSON.create_pretty_state - end if opts - if opts.respond_to? :to_hash - opts = opts.to_hash - elsif opts.respond_to? :to_h - opts = opts.to_h - else - raise TypeError, "can't convert #{opts.class} into Hash" end - state.configure(opts) end - state.generate(obj) end # Sets or returns default options for the JSON.unsafe_load method. |