本文整理了Java中io.restassured.path.json.JsonPath.get()
方法的一些代码示例,展示了JsonPath.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonPath.get()
方法的具体详情如下:
包路径:io.restassured.path.json.JsonPath
类名称:JsonPath
方法名:get
[英]Get a Object graph with no named root element as a Java object. This is just a short-cut for
get("");
or
get("$");
[中]获取没有命名根元素的对象图作为Java对象。这只是一条捷径
<
get("");
或<
get("$");
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a list.
*
* @param path The Object path.
* @param <T> The list type
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public <T> List<T> getList(String path) {
return get(path);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a map.
*
* @param path The Object path.
* @param <K> The type of the expected key
* @param <V> The type of the expected value
* @return The map matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public <K, V> Map<K, V> getMap(String path) {
return get(path);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a map.
*
* @param path The Object path.
* @param <K> The type of the expected key
* @param <V> The type of the expected value
* @return The map matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public <K, V> Map<K, V> getMap(String path) {
return get(path);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a list.
*
* @param path The Object path.
* @param <T> The list type
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public <T> List<T> getList(String path) {
return get(path);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get a Object graph with no named root element as a Java object. This is just a short-cut for
* <p/>
* <pre>
* get("");
* </pre>
* or
* <pre>
* get("$");
* </pre>
*
* @return The object matching the Object graph. This may be any primitive type, a List or a Map. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public <T> T get() {
return get("");
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get a Object graph with no named root element as a Java object. This is just a short-cut for
* <p/>
* <pre>
* get("");
* </pre>
* or
* <pre>
* get("$");
* </pre>
*
* @return The object matching the Object graph. This may be any primitive type, a List or a Map. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public <T> T get() {
return get("");
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a char.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public char getChar(String path) {
return ObjectConverter.convertObjectTo(get(path), Character.class);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a string.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public String getString(String path) {
return ObjectConverter.convertObjectTo(get(path), String.class);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a UUID.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public UUID getUUID(String path) {
return ObjectConverter.convertObjectTo(get(path), UUID.class);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a boolean
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public boolean getBoolean(String path) {
return ObjectConverter.convertObjectTo(get(path), Boolean.class);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a UUID.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public UUID getUUID(String path) {
return ObjectConverter.convertObjectTo(get(path), UUID.class);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a boolean
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public boolean getBoolean(String path) {
return ObjectConverter.convertObjectTo(get(path), Boolean.class);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a char.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public char getChar(String path) {
return ObjectConverter.convertObjectTo(get(path), Character.class);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a string.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public String getString(String path) {
return ObjectConverter.convertObjectTo(get(path), String.class);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a double.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public double getDouble(String path) {
final Object value = get(path);
if (value instanceof Double) {
return (Double) value;
}
return ObjectConverter.convertObjectTo(value, Double.class);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a double.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public double getDouble(String path) {
final Object value = get(path);
if (value instanceof Double) {
return (Double) value;
}
return ObjectConverter.convertObjectTo(value, Double.class);
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a float.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public float getFloat(String path) {
final Object value = get(path);
//Groovy will always return a Double for floating point values.
if (value instanceof Double) {
return ((Double) value).floatValue();
} else {
return ObjectConverter.convertObjectTo(value, Float.class);
}
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a float.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public float getFloat(String path) {
final Object value = get(path);
//Groovy will always return a Double for floating point values.
if (value instanceof Double) {
return ((Double) value).floatValue();
} else {
return ObjectConverter.convertObjectTo(value, Float.class);
}
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a long.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public long getLong(String path) {
//The type returned from Groovy depends on the input, so we need to handle different numerical types.
Object value = get(path);
if (value instanceof Long) {
return (Long) value;
} else if (value instanceof Short) {
return ((Short) value).longValue();
} else if (value instanceof Integer) {
return ((Integer) value).longValue();
} else {
return ObjectConverter.convertObjectTo(value, Long.class);
}
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Get the result of an Object path expression as a short.
*
* @param path The Object path.
* @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
* cannot be casted to the expected type.
*/
public short getShort(String path) {
//The type returned from Groovy depends on the input, so we need to handle different numerical types.
Object value = get(path);
if (value instanceof Short) {
return (Short) value;
} else if (value instanceof Long) {
return ((Long) value).shortValue();
} else if (value instanceof Integer) {
return ((Integer) value).shortValue();
} else {
return ObjectConverter.convertObjectTo(value, Short.class);
}
}
内容来源于网络,如有侵权,请联系作者删除!