提交 14ccb385 编写于 作者: R Rossen Stoyanchev

Handle nested w/o top-level array in Jackson2JsonTokenizer

Issue: SPR-15803
上级 bd0de708
...@@ -152,8 +152,8 @@ class Jackson2Tokenizer implements Function<DataBuffer, Flux<TokenBuffer>> { ...@@ -152,8 +152,8 @@ class Jackson2Tokenizer implements Function<DataBuffer, Flux<TokenBuffer>> {
} }
private boolean isTopLevelArrayToken(JsonToken token) { private boolean isTopLevelArrayToken(JsonToken token) {
return (token == JsonToken.START_ARRAY && this.arrayDepth == 1) || return this.objectDepth == 0 && ((token == JsonToken.START_ARRAY && this.arrayDepth == 1) ||
(token == JsonToken.END_ARRAY && this.arrayDepth == 0); (token == JsonToken.END_ARRAY && this.arrayDepth == 0));
} }
public void endOfInput() { public void endOfInput() {
......
...@@ -57,7 +57,7 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase ...@@ -57,7 +57,7 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase
} }
@Test @Test
public void noTokenizeArrayElements() { public void doNotTokenizeArrayElements() {
this.tokenizer = new Jackson2Tokenizer(this.jsonParser, false); this.tokenizer = new Jackson2Tokenizer(this.jsonParser, false);
testTokenize( testTokenize(
...@@ -116,7 +116,7 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase ...@@ -116,7 +116,7 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase
asList("{\"foo\": \"bar\"}", asList("{\"foo\": \"bar\"}",
"{\"foo\": \"baz\"}")); "{\"foo\": \"baz\"}"));
// SPR-15803 // SPR-15803: nested array
testTokenize( testTokenize(
singletonList("[" + singletonList("[" +
"{\"id\":\"0\",\"start\":[-999999999,1,1],\"end\":[999999999,12,31]}," + "{\"id\":\"0\",\"start\":[-999999999,1,1],\"end\":[999999999,12,31]}," +
...@@ -129,6 +129,11 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase ...@@ -129,6 +129,11 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase
"{\"id\":\"2\",\"start\":[-999999999,1,1],\"end\":[999999999,12,31]}") "{\"id\":\"2\",\"start\":[-999999999,1,1],\"end\":[999999999,12,31]}")
); );
// SPR-15803: nested array, no top-level array
testTokenize(
singletonList("{\"speakerIds\":[\"tastapod\"],\"language\":\"ENGLISH\"}"),
singletonList("{\"speakerIds\":[\"tastapod\"],\"language\":\"ENGLISH\"}"));
testTokenize( testTokenize(
asList("[{\"foo\": \"foofoo\", \"bar\"", asList("[{\"foo\": \"foofoo\", \"bar\"",
": \"barbar\"},{\"foo\": \"foofoofoo\", \"bar\": \"barbarbar\"}]"), ": \"barbar\"},{\"foo\": \"foofoofoo\", \"bar\": \"barbarbar\"}]"),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册