use of com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider in project JsonPath by json-path.
the class ProviderInTest method testJsonPathQuotesJacksonJsonNode.
@Test
public void testJsonPathQuotesJacksonJsonNode() throws Exception {
final Configuration jacksonJsonNode = Configuration.builder().jsonProvider(new JacksonJsonNodeJsonProvider()).mappingProvider(new JacksonMappingProvider()).build();
final DocumentContext ctx = JsonPath.using(jacksonJsonNode).parse(JSON);
final ArrayNode doubleQuoteEqualsResult = ctx.read(DOUBLE_QUOTES_EQUALS_FILTER);
assertEquals("bar", doubleQuoteEqualsResult.get(0).asText());
final ArrayNode singleQuoteEqualsResult = ctx.read(SINGLE_QUOTES_EQUALS_FILTER);
assertEquals(doubleQuoteEqualsResult, singleQuoteEqualsResult);
final ArrayNode doubleQuoteInResult = ctx.read(DOUBLE_QUOTES_IN_FILTER);
assertEquals(doubleQuoteInResult, doubleQuoteEqualsResult);
final ArrayNode singleQuoteInResult = ctx.read(SINGLE_QUOTES_IN_FILTER);
assertEquals(doubleQuoteInResult, singleQuoteInResult);
}
use of com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider in project JsonPath by jayway.
the class IssuesTest method issue_378.
@Test
public void issue_378() {
String json = "{\n" + " \"nodes\": {\n" + " \"unnamed1\": {\n" + " \"ntpServers\": [\n" + " \"1.2.3.4\"\n" + " ]\n" + " }\n" + " }\n" + "}";
Configuration configuration = Configuration.builder().jsonProvider(new JacksonJsonNodeJsonProvider()).mappingProvider(new JacksonMappingProvider()).build();
DocumentContext ctx = JsonPath.using(configuration).parse(json);
String path = "$.nodes[*][?(!([\"1.2.3.4\"] subsetof @.ntpServers))].ntpServers";
JsonPath jsonPath = JsonPath.compile(path);
ctx.read(jsonPath);
}
use of com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider in project JsonPath by json-path.
the class IssuesTest method issue_378.
@Test
public void issue_378() {
String json = "{\n" + " \"nodes\": {\n" + " \"unnamed1\": {\n" + " \"ntpServers\": [\n" + " \"1.2.3.4\"\n" + " ]\n" + " }\n" + " }\n" + "}";
Configuration configuration = Configuration.builder().jsonProvider(new JacksonJsonNodeJsonProvider()).mappingProvider(new JacksonMappingProvider()).build();
DocumentContext ctx = JsonPath.using(configuration).parse(json);
String path = "$.nodes[*][?(!([\"1.2.3.4\"] subsetof @.ntpServers))].ntpServers";
JsonPath jsonPath = JsonPath.compile(path);
ctx.read(jsonPath);
}
use of com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider in project JsonPath by jayway.
the class ProviderInTest method testJsonPathQuotesJacksonJsonNode.
@Test
public void testJsonPathQuotesJacksonJsonNode() throws Exception {
final Configuration jacksonJsonNode = Configuration.builder().jsonProvider(new JacksonJsonNodeJsonProvider()).mappingProvider(new JacksonMappingProvider()).build();
final DocumentContext ctx = JsonPath.using(jacksonJsonNode).parse(JSON);
final ArrayNode doubleQuoteEqualsResult = ctx.read(DOUBLE_QUOTES_EQUALS_FILTER);
assertEquals("bar", doubleQuoteEqualsResult.get(0).asText());
final ArrayNode singleQuoteEqualsResult = ctx.read(SINGLE_QUOTES_EQUALS_FILTER);
assertEquals(doubleQuoteEqualsResult, singleQuoteEqualsResult);
final ArrayNode doubleQuoteInResult = ctx.read(DOUBLE_QUOTES_IN_FILTER);
assertEquals(doubleQuoteInResult, doubleQuoteEqualsResult);
final ArrayNode singleQuoteInResult = ctx.read(SINGLE_QUOTES_IN_FILTER);
assertEquals(doubleQuoteInResult, singleQuoteInResult);
}
use of com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider in project JsonPath by jayway.
the class JacksonJsonNodeJsonProviderTest method mapPropertyWithPOJO.
@Test
public void mapPropertyWithPOJO() {
String someJson = "" + "{\n" + " \"a\": \"a\",\n" + " \"b\": \"b\"\n" + "}";
ObjectMapper om = new ObjectMapper();
om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
Configuration c = Configuration.builder().mappingProvider(new JacksonMappingProvider()).jsonProvider(new JacksonJsonNodeJsonProvider(om)).build();
DocumentContext context = JsonPath.using(c).parse(someJson);
String someJsonStr = context.jsonString();
DocumentContext altered = context.map("$['a', 'b', 'c']", new MapFunction() {
@Override
public Object map(Object currentValue, Configuration configuration) {
return currentValue;
}
});
assertThat(altered.jsonString()).isEqualTo(someJsonStr);
}
Aggregations