From fc4971f34e6fbdd3dfb957bbec488b58e2fc0b8d Mon Sep 17 00:00:00 2001 From: Dai MIKURUBE Date: Mon, 3 Jul 2023 15:56:13 +0900 Subject: [PATCH] Allow multiple matches with JsonPointerBasedFilter JsonParser has not been working well with JSON Pointer for consequent multiple JSONs when used with Jackson 2.7.4+. For example of multiple JSONs in one stream: {"a": {"b": 1}} {"a": {"b": 2}} It happened because Jackson 2.7.3 or earlier ignored the `allowMultipleMatches` option. https://github.com/FasterXML/jackson-core/issues/209 This commit fixes this problem by setting the option when used with Jackson 2.7.4+. --- src/main/java/org/embulk/util/json/JsonParser.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/embulk/util/json/JsonParser.java b/src/main/java/org/embulk/util/json/JsonParser.java index 330a25a..19e3964 100644 --- a/src/main/java/org/embulk/util/json/JsonParser.java +++ b/src/main/java/org/embulk/util/json/JsonParser.java @@ -113,7 +113,12 @@ private static String sampleJsonString(final String json) { private static com.fasterxml.jackson.core.JsonParser wrapWithPointerFilter( final com.fasterxml.jackson.core.JsonParser baseParser, final String offsetInJsonPointer) { - return new FilteringParserDelegate(baseParser, new JsonPointerBasedFilter(offsetInJsonPointer), false, false); + return new FilteringParserDelegate( + baseParser, + new JsonPointerBasedFilter(offsetInJsonPointer), + false, + true // Allow multiple matches + ); } private static class StreamParseContext extends AbstractParseContext implements Stream {