Skip to content

Commit 8c66510

Browse files
dylwyliejon-wei
authored andcommitted
Update jsonpath dependency (#5794)
* Update JSONPath Library Re: #5792 - Add a unit test containing a JSONPath conditional - Update the JSONPath library and no longer exclude the json-smart dependency. - I believe the original reason for excluding this has been fixed: json-path/JsonPath#315 * Add test * Fix test
1 parent 1f700bb commit 8c66510

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

api/src/test/java/io/druid/data/input/impl/JSONParseSpecTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.junit.Test;
3131

3232
import java.io.IOException;
33+
import java.util.ArrayList;
3334
import java.util.Arrays;
3435
import java.util.HashMap;
3536
import java.util.Map;
@@ -79,6 +80,33 @@ public void testParseRow()
7980
Assert.assertNull(parsedRow.get("path_omg2"));
8081
}
8182

83+
@Test
84+
public void testParseRowWithConditional()
85+
{
86+
final JSONParseSpec parseSpec = new JSONParseSpec(
87+
new TimestampSpec("timestamp", "iso", null),
88+
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("foo")), null, null),
89+
new JSONPathSpec(
90+
true,
91+
ImmutableList.of(
92+
new JSONPathFieldSpec(JSONPathFieldType.PATH, "foo", "$.[?(@.maybe_object)].maybe_object.foo.test"),
93+
new JSONPathFieldSpec(JSONPathFieldType.PATH, "bar", "$.[?(@.something_else)].something_else.foo")
94+
)
95+
),
96+
null
97+
);
98+
99+
final Map<String, Object> expected = new HashMap<>();
100+
expected.put("foo", new ArrayList());
101+
expected.put("bar", Arrays.asList("test"));
102+
103+
final Parser<String, Object> parser = parseSpec.makeParser();
104+
final Map<String, Object> parsedRow = parser.parseToMap("{\"something_else\": {\"foo\": \"test\"}}");
105+
106+
Assert.assertNotNull(parsedRow);
107+
Assert.assertEquals(expected, parsedRow);
108+
}
109+
82110
@Test
83111
public void testSerde() throws IOException
84112
{

java-util/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,6 @@
9292
<dependency>
9393
<groupId>com.jayway.jsonpath</groupId>
9494
<artifactId>json-path</artifactId>
95-
<exclusions>
96-
<exclusion>
97-
<groupId>net.minidev</groupId>
98-
<artifactId>json-smart</artifactId>
99-
</exclusion>
100-
</exclusions>
10195
</dependency>
10296
<dependency>
10397
<groupId>net.thisptr</groupId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@
638638
<dependency>
639639
<groupId>com.jayway.jsonpath</groupId>
640640
<artifactId>json-path</artifactId>
641-
<version>2.1.0</version>
641+
<version>2.3.0</version>
642642
</dependency>
643643
<dependency>
644644
<groupId>net.thisptr</groupId>

0 commit comments

Comments
 (0)