diff options
author | Jean Boussier <[email protected]> | 2025-03-26 11:47:51 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2025-03-27 11:37:27 +0900 |
commit | f4529ecbe7adf6cc24bf8f8aa92becbc005e897a (patch) | |
tree | feeff4f1bc07b0381e53f233290b1b34321570d0 /test/json/json_common_interface_test.rb | |
parent | 46ee73f4f6a6fceba4ed6dfe6622c78462a2b1ac (diff) |
[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
Diffstat (limited to 'test/json/json_common_interface_test.rb')
-rw-r--r-- | test/json/json_common_interface_test.rb | 8 |
1 files changed, 6 insertions, 2 deletions
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) |