summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2025-04-24 18:21:23 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-04-25 11:11:21 +0900
commit05f949ebbff5c2b6cce01598cc069472bfbe52d2 (patch)
tree546b6d08f736ca211f99b1e8c4d5a23e703346b9
parent1d65d5ce473ed098a02aa0150f318f3fc69a1e80 (diff)
[ruby/json] Bring back JSON::PRETTY_STATE_PROTOTYPE with a deprecation
Fix: https://github.com/ruby/json/issues/788 `multi_json` rely on it, even though it was never documented as public API. Bringing it back as a method so it can emit a deprecation warning. https://github.com/ruby/json/commit/123121bba2
-rw-r--r--ext/json/lib/json/common.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index 77d024dea0..98bc0ac85a 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -961,6 +961,24 @@ module JSON
load(...)
end
module_function :restore
+
+ class << self
+ private
+
+ def const_missing(const_name)
+ case const_name
+ when :PRETTY_STATE_PROTOTYPE
+ if RUBY_VERSION >= "3.0"
+ warn "JSON::PRETTY_STATE_PROTOTYPE is deprecated and will be removed in json 3.0.0, just use JSON.pretty_generate", uplevel: 1, category: :deprecated
+ else
+ warn "JSON::PRETTY_STATE_PROTOTYPE is deprecated and will be removed in json 3.0.0, just use JSON.pretty_generate", uplevel: 1
+ end
+ state.new(PRETTY_GENERATE_OPTIONS)
+ else
+ super
+ end
+ end
+ end
# :startdoc:
# JSON::Coder holds a parser and generator configuration.