mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
[ruby/json] Respect Coder depth when generating
https://github.com/ruby/json/commit/9c36681b17
This commit is contained in:
parent
78aa8d5b1d
commit
2f192c73cc
@ -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
|
||||
};
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user