提交 b4749169 编写于 作者: A Arjen Poutsma

Support array of scalar values in Jackson2Tokenizer

Issue: SPR-16407
上级 9d0e62ef
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -173,8 +173,9 @@ class Jackson2Tokenizer {
this.tokenBuffer.copyCurrentEvent(this.parser);
}
if ((token == JsonToken.END_OBJECT && this.objectDepth == 0 && (this.arrayDepth == 1 || this.arrayDepth == 0)) ||
(token.isScalarValue()) && this.objectDepth == 0 && this.arrayDepth == 0) {
if (this.objectDepth == 0 &&
(this.arrayDepth == 0 || this.arrayDepth == 1) &&
(token == JsonToken.END_OBJECT || token.isScalarValue())) {
result.add(this.tokenBuffer);
this.tokenBuffer = new TokenBuffer(this.parser);
}
......
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -168,6 +168,10 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase
testTokenize(asList("12.", "34")
,singletonList("12.34"), true);
// SPR-16407
testTokenize(asList("[1", ",2,", "3]"),
asList("1", "2", "3"), true);
}
private void testTokenize(List<String> source, List<String> expected, boolean tokenizeArrayElements) {
......@@ -175,7 +179,7 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase
.map(this::stringBuffer);
Flux<TokenBuffer> tokenBufferFlux =
Jackson2Tokenizer.tokenize(sourceFlux, jsonFactory, tokenizeArrayElements);
Jackson2Tokenizer.tokenize(sourceFlux, this.jsonFactory, tokenizeArrayElements);
Flux<String> result = tokenBufferFlux
.map(tokenBuffer -> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册