Search in sources :

Example 11 with JacksonJsonProvider

use of com.jayway.jsonpath.spi.json.JacksonJsonProvider in project JsonPath by json-path.

the class JsonProviderTest method parse_array.

@Test
public void parse_array() throws Exception {
    JacksonJsonProvider provider = new JacksonJsonProvider();
    Object o = provider.parse(ARRAY);
}
Also used : JacksonJsonProvider(com.jayway.jsonpath.spi.json.JacksonJsonProvider) Test(org.junit.Test)

Example 12 with JacksonJsonProvider

use of com.jayway.jsonpath.spi.json.JacksonJsonProvider in project syndesis by syndesisio.

the class AbstractSwaggerConnectorTest method fetchSwaggerConnectorTemplateFromDeployment.

private static ConnectorTemplate fetchSwaggerConnectorTemplateFromDeployment() {
    final Configuration configuration = // 
    Configuration.builder().jsonProvider(// 
    new JacksonJsonProvider(Json.copyObjectMapperConfiguration())).mappingProvider(// 
    new JacksonMappingProvider(Json.copyObjectMapperConfiguration())).build();
    final List<ConnectorTemplate> templates = JsonPath.using(configuration).parse(AbstractSwaggerConnectorTest.class.getResourceAsStream("/io/syndesis/server/dao/deployment.json")).read("$..[?(@['id'] == 'swagger-connector-template')]", new TypeRef<List<ConnectorTemplate>>() {
    });
    return templates.get(0);
}
Also used : JacksonMappingProvider(com.jayway.jsonpath.spi.mapper.JacksonMappingProvider) ConnectorTemplate(io.syndesis.common.model.connection.ConnectorTemplate) Configuration(com.jayway.jsonpath.Configuration) JacksonJsonProvider(com.jayway.jsonpath.spi.json.JacksonJsonProvider) List(java.util.List)

Example 13 with JacksonJsonProvider

use of com.jayway.jsonpath.spi.json.JacksonJsonProvider in project JsonPath by jayway.

the class TestSuppressExceptions method testSuppressExceptionsIsRespectedPath.

@Test
public void testSuppressExceptionsIsRespectedPath() {
    ParseContext parseContext = JsonPath.using(new Configuration.ConfigurationBuilder().jsonProvider(new JacksonJsonProvider()).mappingProvider(new JacksonMappingProvider()).options(Option.SUPPRESS_EXCEPTIONS, Option.AS_PATH_LIST).build());
    String json = "{}";
    List<String> result = parseContext.parse(json).read(JsonPath.compile("$.missing"));
    assertThat(result).isEmpty();
}
Also used : JacksonMappingProvider(com.jayway.jsonpath.spi.mapper.JacksonMappingProvider) JacksonJsonProvider(com.jayway.jsonpath.spi.json.JacksonJsonProvider) Test(org.junit.Test)

Example 14 with JacksonJsonProvider

use of com.jayway.jsonpath.spi.json.JacksonJsonProvider in project JsonPath by jayway.

the class TestSuppressExceptions method testSuppressExceptionsIsRespected.

@Test
public void testSuppressExceptionsIsRespected() {
    ParseContext parseContext = JsonPath.using(new Configuration.ConfigurationBuilder().jsonProvider(new JacksonJsonProvider()).mappingProvider(new JacksonMappingProvider()).options(Option.SUPPRESS_EXCEPTIONS).build());
    String json = "{}";
    assertNull(parseContext.parse(json).read(JsonPath.compile("$.missing")));
}
Also used : JacksonMappingProvider(com.jayway.jsonpath.spi.mapper.JacksonMappingProvider) JacksonJsonProvider(com.jayway.jsonpath.spi.json.JacksonJsonProvider) Test(org.junit.Test)

Example 15 with JacksonJsonProvider

use of com.jayway.jsonpath.spi.json.JacksonJsonProvider in project JsonPath by jayway.

the class ProviderInTest method testJsonPathQuotesJackson.

@Test
public void testJsonPathQuotesJackson() throws Exception {
    final Configuration jackson = Configuration.builder().jsonProvider(new JacksonJsonProvider()).mappingProvider(new JacksonMappingProvider()).build();
    final DocumentContext ctx = JsonPath.using(jackson).parse(JSON);
    final List<String> doubleQuoteEqualsResult = ctx.read(DOUBLE_QUOTES_EQUALS_FILTER);
    assertEquals(Lists.newArrayList("bar"), doubleQuoteEqualsResult);
    final List<String> singleQuoteEqualsResult = ctx.read(SINGLE_QUOTES_EQUALS_FILTER);
    assertEquals(doubleQuoteEqualsResult, singleQuoteEqualsResult);
    final List<String> doubleQuoteInResult = ctx.read(DOUBLE_QUOTES_IN_FILTER);
    assertEquals(doubleQuoteInResult, doubleQuoteEqualsResult);
    final List<String> singleQuoteInResult = ctx.read(SINGLE_QUOTES_IN_FILTER);
    assertEquals(doubleQuoteInResult, singleQuoteInResult);
}
Also used : JacksonMappingProvider(com.jayway.jsonpath.spi.mapper.JacksonMappingProvider) JacksonJsonProvider(com.jayway.jsonpath.spi.json.JacksonJsonProvider) Test(org.junit.Test)

Aggregations

JacksonJsonProvider (com.jayway.jsonpath.spi.json.JacksonJsonProvider)15 JacksonMappingProvider (com.jayway.jsonpath.spi.mapper.JacksonMappingProvider)8 Test (org.junit.Test)8 Configuration (com.jayway.jsonpath.Configuration)4 JsonProvider (com.jayway.jsonpath.spi.json.JsonProvider)3 MappingProvider (com.jayway.jsonpath.spi.mapper.MappingProvider)3 EnumSet (java.util.EnumSet)3 Set (java.util.Set)3 Option (com.jayway.jsonpath.Option)2 List (java.util.List)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Defaults (com.jayway.jsonpath.Configuration.Defaults)1 ReadContext (com.jayway.jsonpath.ReadContext)1 LRUCache (com.jayway.jsonpath.spi.cache.LRUCache)1 AssetsBundle (io.dropwizard.assets.AssetsBundle)1 MultiPartBundle (io.dropwizard.forms.MultiPartBundle)1 ConnectorTemplate (io.syndesis.common.model.connection.ConnectorTemplate)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 JSONObject (org.json.simple.JSONObject)1