com.jayway.jsonpath.spi.json.JsonProvider.unwrap()方法的使用及代码示例

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

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

JsonProvider.unwrap介绍

[英]Extracts a value from a wrapper object. For JSON providers that to not wrap values, this will usually be the object itself.
[中]从包装器对象中提取值。对于不包装值的JSON提供程序,这通常是对象本身。

代码示例

代码示例来源:origin: json-path/JsonPath

@SuppressWarnings("unchecked")
@Override
public <T> T getValue(boolean unwrap) {
  if (path.isDefinite()) {
    if(resultIndex == 0){
      throw new PathNotFoundException("No results for path: " + path.toString());
    }
    int len = jsonProvider().length(valueResult);
    Object value = (len > 0) ? jsonProvider().getArrayIndex(valueResult, len-1) : null;
    if (value != null && unwrap){
     value = jsonProvider().unwrap(value);
    }
    return (T) value;
  }
  return (T)valueResult;
}

代码示例来源:origin: json-path/JsonPath

/**
 * Verify the function returns the correct result based on the input expectedValue
 *
 * @param pathExpr
 *      The path expression to execute
 *
 * @param json
 *      The json document (actual content) to parse
 *
 * @param expectedValue
 *      The expected value to be returned from the test
 */
protected void verifyFunction(Configuration conf, String pathExpr, String json, Object expectedValue) {
  Object result = using(conf).parse(json).read(pathExpr);
  assertThat(conf.jsonProvider().unwrap(result)).isEqualTo(expectedValue);
}

代码示例来源:origin: json-path/JsonPath

res = path.evaluate(doc, ctx.root(), ctx.configuration()).getValue();
res = ctx.configuration().jsonProvider().unwrap(res);

代码示例来源:origin: com.jayway.jsonpath/json-path

@SuppressWarnings("unchecked")
@Override
public <T> T getValue(boolean unwrap) {
  if (path.isDefinite()) {
    if(resultIndex == 0){
      throw new PathNotFoundException("No results for path: " + path.toString());
    }
    int len = jsonProvider().length(valueResult);
    Object value = (len > 0) ? jsonProvider().getArrayIndex(valueResult, len-1) : null;
    if (value != null && unwrap){
     value = jsonProvider().unwrap(value);
    }
    return (T) value;
  }
  return (T)valueResult;
}

代码示例来源:origin: com.jayway.jsonpath/json-path

res = path.evaluate(doc, ctx.root(), ctx.configuration()).getValue();
res = ctx.configuration().jsonProvider().unwrap(res);

代码示例来源:origin: com.github.lafa.jsonpath/json-path

@SuppressWarnings("unchecked")
@Override
public <T> T getValue(boolean unwrap) {
  if (path.isDefinite()) {
    if(resultIndex == 0){
      throw new PathNotFoundException("No results for path: " + path.toString());
    }
    int len = jsonProvider().length(valueResult);
    Object value = (len > 0) ? jsonProvider().getArrayIndex(valueResult, len-1) : null;
    if (value != null && unwrap){
     value = jsonProvider().unwrap(value);
    }
    return (T) value;
  }
  return (T)valueResult;
}

代码示例来源:origin: com.github.lafa.jsonpath/json-path

res = path.evaluate(doc, ctx.root(), ctx.configuration()).getValue();
res = ctx.configuration().jsonProvider().unwrap(res);

相关文章