com.jayway.jsonpath.spi.mapper.JacksonMappingProvider Java Examples
The following examples show how to use
com.jayway.jsonpath.spi.mapper.JacksonMappingProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MaskTest.java From light-4j with Apache License 2.0 | 6 votes |
@BeforeClass public static void runOnceBeforeClass() { Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.noneOf(Option.class); } }); }
Example #2
Source File: LightServer.java From light with Apache License 2.0 | 6 votes |
static void configJsonPath() { Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.noneOf(Option.class); } }); }
Example #3
Source File: InstructionsPropertiesTest.java From querqy with Apache License 2.0 | 6 votes |
@Test public void testMatches() { final Map<String, Object> props = new HashMap<>(); props.put("p1", 1); props.put("p2", "2"); props.put("p3", Arrays.asList("3", 33)); final Map<String, Object> p4 = new HashMap<>(); p4.put("p41", "41"); p4.put("p42", 42); props.put("p4", p4); final InstructionsProperties instructionsProperties = new InstructionsProperties(props, Configuration.builder() .jsonProvider(new JacksonJsonProvider()).mappingProvider(new JacksonMappingProvider()).build()); assertTrue(instructionsProperties.matches("$[?(@.p2 == '2')]")); assertFalse(instructionsProperties.matches("$.[?(@.p2 == 1)]")); assertTrue(instructionsProperties.matches("$.p3[?(@ == '3')]")); assertTrue(instructionsProperties.matches("$.p4[?(@.p42 == 42)]")); assertTrue(instructionsProperties.matches("$.p4[?(@.p42 > 5)]")); }
Example #4
Source File: PropertiesBuilder.java From querqy with Apache License 2.0 | 6 votes |
public PropertiesBuilder() { objectMapper = new ObjectMapper(); objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); objectMapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true); objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); objectMapper.configure(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS, true); objectMapper.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true); jsonPathConfiguration = Configuration.builder() .jsonProvider(new JacksonJsonProvider()) .mappingProvider(new JacksonMappingProvider()).build(); jsonPathConfiguration.addOptions(Option.ALWAYS_RETURN_LIST); primitiveProperties = new HashMap<>(); jsonObjectString = new StringBuilder(); }
Example #5
Source File: JsonPathStartupHookProvider.java From light-4j with Apache License 2.0 | 6 votes |
static void configJsonPath() { Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.noneOf(Option.class); } }); }
Example #6
Source File: TestCaseLoaderTest.java From interface-test with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { com.jayway.jsonpath.Configuration.setDefaults(new com.jayway.jsonpath.Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.noneOf(Option.class); } }); }
Example #7
Source File: InterfaceTestApplication.java From interface-test with Apache License 2.0 | 6 votes |
@SuppressWarnings("WeakerAccess") public void init(){ // jsonpath配置初始化 com.jayway.jsonpath.Configuration.setDefaults(new com.jayway.jsonpath.Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.noneOf(Option.class); } }); }
Example #8
Source File: JsonPathIntegrationCustomizer.java From syndesis with Apache License 2.0 | 6 votes |
@Override public Integration apply(Integration integration) { if (ObjectHelper.isEmpty(expression)) { return integration; } try { final Configuration configuration = Configuration.builder() .jsonProvider(new JacksonJsonProvider(JsonUtils.copyObjectMapperConfiguration())) .mappingProvider(new JacksonMappingProvider(JsonUtils.copyObjectMapperConfiguration())) .build(); DocumentContext json = JsonPath.using(configuration).parse(JsonUtils.writer().forType(Integration.class).writeValueAsString(integration)); if (ObjectHelper.isEmpty(key)) { json.set(expression, value); } else { json.put(expression, key, value); } return JsonUtils.reader().forType(Integration.class).readValue(json.jsonString()); } catch (IOException e) { throw new IllegalStateException("Failed to evaluate json path expression on integration object", e); } }
Example #9
Source File: CloudFoundryAcceptanceTest.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
@BeforeEach void configureJsonPath() { Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jacksonJsonProvider = new JacksonJsonProvider(); private final MappingProvider jacksonMappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jacksonJsonProvider; } @Override public MappingProvider mappingProvider() { return jacksonMappingProvider; } @Override public Set<Option> options() { return EnumSet.noneOf(Option.class); } }); }
Example #10
Source File: NashornTest.java From interface-test with Apache License 2.0 | 5 votes |
@Test public void test() throws ScriptException { com.jayway.jsonpath.Configuration.setDefaults(new com.jayway.jsonpath.Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.noneOf(Option.class); } }); // DocumentContext doc = JsonPath.parse(this.getClass().getClassLoader().getResourceAsStream("nashorn.js")); //InvalidJsonException // TestSuit testSuit = doc.read("$", TestSuit.class); ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); ScriptEngine nashorn = scriptEngineManager.getEngineByName("nashorn"); nashorn.eval(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("nashorn.js")));//ScriptException->ParserException Object obj = nashorn.eval("JSON.stringify(testSuit)"); System.out.println(obj); }
Example #11
Source File: JsonPathUtilsTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testConfiguration() { JsonPathUtils.setJacksonConfiguration(); Configuration configuration = Configuration.defaultConfiguration(); Assertions.assertTrue(configuration.jsonProvider() instanceof JacksonJsonProvider); Assertions.assertTrue(configuration.mappingProvider() instanceof JacksonMappingProvider); }
Example #12
Source File: JsonUtils.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
public static DocumentContext toJsonPath(Object object) { Configuration configuration = Configuration.builder() .jsonProvider(new JacksonJsonProvider()) .mappingProvider(new JacksonMappingProvider()) .build(); return JsonPath.parse(toJson(object), configuration); }
Example #13
Source File: SoapConnectorTemplate.java From syndesis with Apache License 2.0 | 5 votes |
private static ConnectorTemplate fetchSoapConnectorTemplateFromDeployment() { final Configuration configuration = Configuration.builder()// .jsonProvider(new JacksonJsonProvider(JsonUtils.copyObjectMapperConfiguration()))// .mappingProvider(new JacksonMappingProvider(JsonUtils.copyObjectMapperConfiguration()))// .build(); final List<ConnectorTemplate> templates = JsonPath.using(configuration) .parse(SoapConnectorTemplate.class.getResourceAsStream("/io/syndesis/server/dao/deployment.json")) .read("$..[?(@['id'] == 'soap-connector-template')]", new TypeRef<List<ConnectorTemplate>>() { // type token pattern }); return templates.get(0); }
Example #14
Source File: ApiConnectorTemplate.java From syndesis with Apache License 2.0 | 5 votes |
private static ConnectorTemplate fetchSwaggerConnectorTemplateFromDeployment() { final Configuration configuration = Configuration.builder()// .jsonProvider(new JacksonJsonProvider(JsonUtils.copyObjectMapperConfiguration()))// .mappingProvider(new JacksonMappingProvider(JsonUtils.copyObjectMapperConfiguration()))// .build(); final List<ConnectorTemplate> templates = JsonPath.using(configuration) .parse(ApiConnectorTemplate.class.getResourceAsStream("/io/syndesis/server/dao/deployment.json")) .read("$..[?(@['id'] == 'swagger-connector-template')]", new TypeRef<List<ConnectorTemplate>>() { // type token pattern }); return templates.get(0); }
Example #15
Source File: JacksonJsonDataFormat.java From camunda-spin with Apache License 2.0 | 5 votes |
public JacksonJsonDataFormat(String name, ObjectMapper objectMapper) { this(name, objectMapper, new ConfigurationBuilder() .jsonProvider(new JacksonJsonProvider(objectMapper)) .mappingProvider(new JacksonMappingProvider(objectMapper)) .build()); }
Example #16
Source File: JsonTestUtils.java From spring-credhub with Apache License 2.0 | 4 votes |
public static DocumentContext toJsonPath(Object object) { Configuration configuration = Configuration.builder().jsonProvider(new JacksonJsonProvider()) .mappingProvider(new JacksonMappingProvider()).build(); return JsonPath.parse(toJson(object), configuration); }
Example #17
Source File: PackageUtils.java From lucene-solr with Apache License 2.0 | 4 votes |
public static Configuration jsonPathConfiguration() { MappingProvider provider = new JacksonMappingProvider(); JsonProvider jsonProvider = new JacksonJsonProvider(); Configuration c = Configuration.builder().jsonProvider(jsonProvider).mappingProvider(provider).options(com.jayway.jsonpath.Option.REQUIRE_PROPERTIES).build(); return c; }
Example #18
Source File: IronTestApplication.java From irontest with Apache License 2.0 | 4 votes |
@Override public void initialize(Bootstrap<IronTestConfiguration> bootstrap) { bootstrap.addCommand(new UpgradeCommand()); bootstrap.addBundle(new AssetsBundle("/assets/app", "/ui", "index.htm", "ui")); bootstrap.addBundle(new AssetsBundle("/META-INF/resources/webjars", "/ui/lib", null, "lib")); bootstrap.addBundle(new AssetsBundle("/assets/mockserver", "/ui/mockserver", "mockserver.htm", "mockserver")); bootstrap.addBundle(new AssetsBundle("/assets/common", "/ui/common", null, "common")); bootstrap.addBundle(jaxWsBundle); bootstrap.addBundle(new MultiPartBundle()); bootstrap.addBundle(new ViewBundle<IronTestConfiguration>(){ @Override public Map<String, Map<String, String>> getViewConfiguration(IronTestConfiguration config) { return config.getViewRendererConfiguration(); } }); Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.noneOf(Option.class); } }); // configure the Jackson ObjectMapper used by JAX-RS (Jersey) ObjectMapper objectMapper = bootstrap.getObjectMapper(); objectMapper.disable(MapperFeature.DEFAULT_VIEW_INCLUSION); IronTestUtils.addMixInsForWireMock(objectMapper); }
Example #19
Source File: JSONMapParser.java From metron with Apache License 2.0 | 4 votes |
@Override public void configure(Map<String, Object> config) { setReadCharset(config); String strategyStr = (String) config.getOrDefault(MAP_STRATEGY_CONFIG, MapStrategy.DROP.name()); mapStrategy = MapStrategy.valueOf(strategyStr); overrideOriginalString = (Boolean) config.getOrDefault(OVERRIDE_ORIGINAL_STRING, false); if (config.containsKey(JSONP_QUERY)) { typeRef = new TypeRef<List<Map<String, Object>>>() { }; jsonpQuery = (String) config.get(JSONP_QUERY); if (!StringUtils.isBlank(jsonpQuery) && config.containsKey(WRAP_JSON)) { Object wrapObject = config.get(WRAP_JSON); if (wrapObject instanceof String) { wrapJson = Boolean.valueOf((String)wrapObject); } else if (wrapObject instanceof Boolean) { wrapJson = (Boolean) config.get(WRAP_JSON); } String entityName = (String)config.get(WRAP_ENTITY_NAME); if (!StringUtils.isBlank(entityName)) { wrapEntityName = entityName; } } Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.of(Option.SUPPRESS_EXCEPTIONS); } }); if (CacheProvider.getCache() == null) { CacheProvider.setCache(new LRUCache(100)); } } }