From f4529ecbe7adf6cc24bf8f8aa92becbc005e897a Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 26 Mar 2025 11:47:51 +0100 Subject: [ruby/json] Deprecate all `*_default_options` Globally changing the behavior of the library is a bad idea, as many different libraries may rely on `json` and may not expect it and likely never tested that a different default config works for them. If you need to change the behavior of JSON, it's best to do it only locally, and not globally. In addition the new `JSON::Coder` interface is much more suited for that. Another reason for the deprecation is that it's impossible to make `JSON.load` and `JSON.dump` Ractor-safe with such API. https://github.com/ruby/json/commit/172762c6e4 --- test/json/json_common_interface_test.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/json/json_common_interface_test.rb b/test/json/json_common_interface_test.rb index 1f157da026..96f7ccdf92 100644 --- a/test/json/json_common_interface_test.rb +++ b/test/json/json_common_interface_test.rb @@ -174,9 +174,9 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase end def test_dump_should_modify_defaults - max_nesting = JSON.dump_default_options[:max_nesting] + max_nesting = JSON._dump_default_options[:max_nesting] dump([], StringIO.new, 10) - assert_equal max_nesting, JSON.dump_default_options[:max_nesting] + assert_equal max_nesting, JSON._dump_default_options[:max_nesting] end def test_JSON @@ -211,6 +211,10 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase end end + def test_deprecated_dump_default_options + assert JSON.dump_default_options + end + private def with_external_encoding(encoding) -- cgit v1.2.3