Skip to content

Commit 2f192c7

Browse files
etiennebarriematzbot
authored andcommitted
[ruby/json] Respect Coder depth when generating
ruby/json@9c36681b17
1 parent 78aa8d5 commit 2f192c7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ext/json/generator/generator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ static VALUE cState_generate_new(int argc, VALUE *argv, VALUE self)
15491549
.buffer = &buffer,
15501550
.vstate = Qfalse,
15511551
.state = state,
1552-
.depth = 0,
1552+
.depth = state->depth,
15531553
.obj = obj,
15541554
.func = generate_json
15551555
};

test/json/json_coder_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def test_json_coder_string_invalid_encoding
134134

135135
def test_depth
136136
coder = JSON::Coder.new(object_nl: "\n", array_nl: "\n", space: " ", indent: " ", depth: 1)
137-
assert_equal %({\n "foo": 42\n}), coder.dump(foo: 42)
137+
assert_equal %({\n "foo": 42\n }), coder.dump(foo: 42)
138138
end
139139

140140
def test_nesting_recovery

0 commit comments

Comments
 (0)