diff options
| author | Étienne Barrié <etienne.barrie@gmail.com> | 2025-11-24 17:41:33 +0100 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-11-27 13:01:57 +0000 |
| commit | 2f192c73cccdfd81e4ac2206feadc48b2757c19c (patch) | |
| tree | c688c5a1b5b11013c9fed645cfeb6dd700594c48 | |
| parent | 78aa8d5b1d62a04d7cb5492f653266c99f4c55a2 (diff) | |
[ruby/json] Respect Coder depth when generating
https://github.com/ruby/json/commit/9c36681b17
| -rw-r--r-- | ext/json/generator/generator.c | 2 | ||||
| -rwxr-xr-x | test/json/json_coder_test.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c index 32a9b48513..6ece9f0538 100644 --- a/ext/json/generator/generator.c +++ b/ext/json/generator/generator.c @@ -1549,7 +1549,7 @@ static VALUE cState_generate_new(int argc, VALUE *argv, VALUE self) .buffer = &buffer, .vstate = Qfalse, .state = state, - .depth = 0, + .depth = state->depth, .obj = obj, .func = generate_json }; diff --git a/test/json/json_coder_test.rb b/test/json/json_coder_test.rb index 1f9bc814e3..47e12ff919 100755 --- a/test/json/json_coder_test.rb +++ b/test/json/json_coder_test.rb @@ -134,7 +134,7 @@ class JSONCoderTest < Test::Unit::TestCase def test_depth coder = JSON::Coder.new(object_nl: "\n", array_nl: "\n", space: " ", indent: " ", depth: 1) - assert_equal %({\n "foo": 42\n}), coder.dump(foo: 42) + assert_equal %({\n "foo": 42\n }), coder.dump(foo: 42) end def test_nesting_recovery |
