本文整理了Java中io.restassured.path.json.JsonPath.using()
方法的一些代码示例,展示了JsonPath.using()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonPath.using()
方法的具体详情如下:
包路径:io.restassured.path.json.JsonPath
类名称:JsonPath
方法名:using
[英]Configure JsonPath to use a specific Gson object mapper factory
[中]配置JsonPath以使用特定的Gson对象映射器工厂
代码示例来源:origin: camunda/camunda-bpm-platform
public static JsonPath from(String json) {
return JsonPath.from(json).using(new DefaultJackson2ObjectMapperFactory() {
public ObjectMapper create(Class cls, String charset) {
return JacksonConfigurator.configureObjectMapper(super.create(cls, charset));
}
});
}
代码示例来源:origin: ctco/cukes
private static <T> Object retrieveValueByPath(ContentProvider<T> contentProvider, Object o, String path) {
String contentType = contentProvider.getContentType(o);
String body = contentProvider.getValue(o);
Object value;
if (containsIgnoreCase(contentType, "xml")) {
XmlPathConfig config = new XmlPathConfig().disableLoadingOfExternalDtd();
XmlPath xmlPath = new XmlPath(body);
value = xmlPath.using(config).get(path);
} else if (containsIgnoreCase(contentType, "html")) {
XmlPath htmlPath = new XmlPath(XmlPath.CompatibilityMode.HTML, body);
List<Object> list = htmlPath.getList(path);
value =
list.size() > 1
? list
: htmlPath.getString(path);
} else {
JsonPathConfig config = new JsonPathConfig().numberReturnType(JsonPathConfig.NumberReturnType.BIG_DECIMAL);
JsonPath jsonPath = new JsonPath(body);
value = jsonPath.using(config).get(path);
}
return value;
}
内容来源于网络,如有侵权,请联系作者删除!