io.restassured.path.json.JsonPath.objectToString()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中io.restassured.path.json.JsonPath.objectToString()方法的一些代码示例,展示了JsonPath.objectToString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonPath.objectToString()方法的具体详情如下:
包路径:io.restassured.path.json.JsonPath
类名称:JsonPath
方法名:objectToString

JsonPath.objectToString介绍

暂无

代码示例

代码示例来源:origin: rest-assured/rest-assured

/**
 * Get the result of an Object path expression as a list.
 *
 * @param path        The Object path.
 * @param genericType The generic list type
 * @param <T>         The 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, Class<T> genericType) {
  if (genericType == null) {
    throw new IllegalArgumentException("Generic type cannot be null");
  }
  final List<T> original = get(path);
  final List<T> newList = new LinkedList<T>();
  if (original != null) {
    for (T t : original) {
      T e;
      if (t instanceof Map && !genericType.isAssignableFrom(Map.class)) {
        // TODO Avoid double parsing
        String str = objectToString(t);
        e = jsonStringToObject(str, genericType);
      } else {
        e = ObjectConverter.convertObjectTo(t, genericType);
      }
      newList.add(e);
    }
  }
  return Collections.unmodifiableList(newList);
}

代码示例来源:origin: rest-assured/rest-assured

/**
 * Get the result of an Object path expression as a list.
 *
 * @param path        The Object path.
 * @param genericType The generic list type
 * @param <T>         The 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, Class<T> genericType) {
  if (genericType == null) {
    throw new IllegalArgumentException("Generic type cannot be null");
  }
  final List<T> original = get(path);
  final List<T> newList = new LinkedList<T>();
  if (original != null) {
    for (T t : original) {
      T e;
      if (t instanceof Map && !genericType.isAssignableFrom(Map.class)) {
        // TODO Avoid double parsing
        String str = objectToString(t);
        e = jsonStringToObject(str, genericType);
      } else {
        e = ObjectConverter.convertObjectTo(t, genericType);
      }
      newList.add(e);
    }
  }
  return Collections.unmodifiableList(newList);
}

代码示例来源:origin: rest-assured/rest-assured

} else if (object instanceof List || object instanceof Map) {
  object = objectToString(object);
} else {
  return ObjectConverter.convertObjectTo(object, objectType);

代码示例来源:origin: rest-assured/rest-assured

} else if (object instanceof List || object instanceof Map) {
  object = objectToString(object);
} else {
  return ObjectConverter.convertObjectTo(object, objectType);

代码示例来源:origin: io.rest-assured/json-path

/**
 * Get the result of an Object path expression as a list.
 *
 * @param path        The Object path.
 * @param genericType The generic list type
 * @param <T>         The 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, Class<T> genericType) {
  if (genericType == null) {
    throw new IllegalArgumentException("Generic type cannot be null");
  }
  final List<T> original = get(path);
  final List<T> newList = new LinkedList<T>();
  if (original != null) {
    for (T t : original) {
      T e;
      if (t instanceof Map && !genericType.isAssignableFrom(Map.class)) {
        // TODO Avoid double parsing
        String str = objectToString(t);
        e = jsonStringToObject(str, genericType);
      } else {
        e = ObjectConverter.convertObjectTo(t, genericType);
      }
      newList.add(e);
    }
  }
  return Collections.unmodifiableList(newList);
}

代码示例来源:origin: io.rest-assured/json-path

} else if (object instanceof List || object instanceof Map) {
  object = objectToString(object);
} else {
  return ObjectConverter.convertObjectTo(object, objectType);

相关文章