mirror of https://github.com/apache/druid.git
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: https://github.com/json-path/JsonPath/pull/315 * Add test * Fix test
This commit is contained in:
parent
1f700bb880
commit
8c6651022d
|
@ -30,6 +30,7 @@ import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -79,6 +80,33 @@ public class JSONParseSpecTest
|
||||||
Assert.assertNull(parsedRow.get("path_omg2"));
|
Assert.assertNull(parsedRow.get("path_omg2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParseRowWithConditional()
|
||||||
|
{
|
||||||
|
final JSONParseSpec parseSpec = new JSONParseSpec(
|
||||||
|
new TimestampSpec("timestamp", "iso", null),
|
||||||
|
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("foo")), null, null),
|
||||||
|
new JSONPathSpec(
|
||||||
|
true,
|
||||||
|
ImmutableList.of(
|
||||||
|
new JSONPathFieldSpec(JSONPathFieldType.PATH, "foo", "$.[?(@.maybe_object)].maybe_object.foo.test"),
|
||||||
|
new JSONPathFieldSpec(JSONPathFieldType.PATH, "bar", "$.[?(@.something_else)].something_else.foo")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
final Map<String, Object> expected = new HashMap<>();
|
||||||
|
expected.put("foo", new ArrayList());
|
||||||
|
expected.put("bar", Arrays.asList("test"));
|
||||||
|
|
||||||
|
final Parser<String, Object> parser = parseSpec.makeParser();
|
||||||
|
final Map<String, Object> parsedRow = parser.parseToMap("{\"something_else\": {\"foo\": \"test\"}}");
|
||||||
|
|
||||||
|
Assert.assertNotNull(parsedRow);
|
||||||
|
Assert.assertEquals(expected, parsedRow);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerde() throws IOException
|
public void testSerde() throws IOException
|
||||||
{
|
{
|
||||||
|
|
|
@ -92,12 +92,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.jsonpath</groupId>
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
<artifactId>json-path</artifactId>
|
<artifactId>json-path</artifactId>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>net.minidev</groupId>
|
|
||||||
<artifactId>json-smart</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.thisptr</groupId>
|
<groupId>net.thisptr</groupId>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -638,7 +638,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.jsonpath</groupId>
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
<artifactId>json-path</artifactId>
|
<artifactId>json-path</artifactId>
|
||||||
<version>2.1.0</version>
|
<version>2.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.thisptr</groupId>
|
<groupId>net.thisptr</groupId>
|
||||||
|
|
Loading…
Reference in New Issue