use of com.jayway.jsonpath.spi.json.JacksonJsonProvider in project JsonPath by jayway.
the class JsonProviderTest method parse_array.
@Test
public void parse_array() throws Exception {
JacksonJsonProvider provider = new JacksonJsonProvider();
Object o = provider.parse(ARRAY);
}
use of com.jayway.jsonpath.spi.json.JacksonJsonProvider in project xm-ms-entity by xm-online.
the class FixedDefaultJsonUnmarshaller method unmarshal.
@Override
public <T> T unmarshal(final Class<T> resultClass, final String json) throws IOException {
final JacksonJsonProvider jacksonJsonProvider = new JacksonJsonProvider(objectMapper);
final Configuration jwayConfiguration = Configuration.defaultConfiguration().jsonProvider(jacksonJsonProvider);
// for JSONPath
final ReadContext jwayReadContext = using(jwayConfiguration).parse(json);
try {
return recursivelyProcessAllFields(resultClass.newInstance(), jwayReadContext, new ArrayList<String>());
} catch (InstantiationException | IllegalAccessException e) {
throw new IllegalArgumentException(e);
}
}
use of com.jayway.jsonpath.spi.json.JacksonJsonProvider in project metron by apache.
the class JSONMapParser method configure.
@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));
}
}
}
use of com.jayway.jsonpath.spi.json.JacksonJsonProvider in project geode by apache.
the class UseJacksonForJsonPathRule method before.
/**
* Override to set up your specific external resource.
*/
@Override
public void before() {
saveDefaults();
Configuration.setDefaults(new 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);
}
});
}
use of com.jayway.jsonpath.spi.json.JacksonJsonProvider in project irontest by zheng-wang.
the class IronTestApplication method initialize.
@Override
public void initialize(Bootstrap<IronTestConfiguration> bootstrap) {
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);
}
Aggregations