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

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

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

JsonProvider.getPropertyKeys介绍

[英]Returns the keys from the given object
[中]返回给定对象的键

代码示例

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

private static boolean hasProperty(String property, Object model, EvaluationContextImpl ctx) {
  return ctx.jsonProvider().getPropertyKeys(model).contains(property);
}

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

Collection<String> keys = ctx.jsonProvider().getPropertyKeys(model);
return keys.containsAll(propertyPathToken.getProperties());

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

@Override
public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {
  if (ctx.jsonProvider().isMap(model)) {
    for (String property : ctx.jsonProvider().getPropertyKeys(model)) {
      handleObjectProperty(currentPath, model, ctx, Collections.singletonList(property));
    }
  } else if (ctx.jsonProvider().isArray(model)) {
    for (int idx = 0; idx < ctx.jsonProvider().length(model); idx++) {
      try {
        handleArrayIndex(idx, currentPath, model, ctx);
      } catch (PathNotFoundException p){
        if(ctx.options().contains(Option.REQUIRE_PROPERTIES)){
          throw p;
        }
      }
    }
  }
}

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

public static void walkObject(PathToken pt, String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx, Predicate predicate) {
  if (predicate.matches(model)) {
    pt.evaluate(currentPath, parent, model, ctx);
  }
  Collection<String> properties = ctx.jsonProvider().getPropertyKeys(model);
  for (String property : properties) {
    String evalPath = currentPath + "['" + property + "']";
    Object propertyModel = ctx.jsonProvider().getMapValue(model, property);
    if (propertyModel != JsonProvider.UNDEFINED) {
      walk(pt, evalPath, PathRef.create(model, property), propertyModel, ctx, predicate);
    }
  }
}

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

private static boolean hasProperty(String property, Object model, EvaluationContextImpl ctx) {
  return ctx.jsonProvider().getPropertyKeys(model).contains(property);
}

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

Collection<String> keys = ctx.jsonProvider().getPropertyKeys(model);
return keys.containsAll(propertyPathToken.getProperties());

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

@Override
public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {
  if (ctx.jsonProvider().isMap(model)) {
    for (String property : ctx.jsonProvider().getPropertyKeys(model)) {
      handleObjectProperty(currentPath, model, ctx, asList(property));
    }
  } else if (ctx.jsonProvider().isArray(model)) {
    for (int idx = 0; idx < ctx.jsonProvider().length(model); idx++) {
      try {
        handleArrayIndex(idx, currentPath, model, ctx);
      } catch (PathNotFoundException p){
        if(ctx.options().contains(Option.REQUIRE_PROPERTIES)){
          throw p;
        }
      }
    }
  }
}

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

public static void walkObject(PathToken pt, String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx, Predicate predicate) {
  if (predicate.matches(model)) {
    pt.evaluate(currentPath, parent, model, ctx);
  }
  Collection<String> properties = ctx.jsonProvider().getPropertyKeys(model);
  for (String property : properties) {
    String evalPath = currentPath + "['" + property + "']";
    Object propertyModel = ctx.jsonProvider().getMapValue(model, property);
    if (propertyModel != JsonProvider.UNDEFINED) {
      walk(pt, evalPath, PathRef.create(model, property), propertyModel, ctx, predicate);
    }
  }
}

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

private static boolean hasProperty(String property, Object model, EvaluationContextImpl ctx) {
  return ctx.jsonProvider().getPropertyKeys(model).contains(property);
}

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

Collection<String> keys = ctx.jsonProvider().getPropertyKeys(model);
return keys.containsAll(propertyPathToken.getProperties());

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

public static void walkObject(PathToken pt, String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx, Predicate predicate) {
  if (predicate.matches(model)) {
    pt.evaluate(currentPath, parent, model, ctx);
  }
  Collection<String> properties = ctx.jsonProvider().getPropertyKeys(model);
  for (String property : properties) {
    String evalPath = currentPath + "['" + property + "']";
    Object propertyModel = ctx.jsonProvider().getMapValue(model, property);
    if (propertyModel != JsonProvider.UNDEFINED) {
      walk(pt, evalPath, PathRef.create(model, property), propertyModel, ctx, predicate);
    }
  }
}

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

@Override
public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {
  if (ctx.jsonProvider().isMap(model)) {
    for (String property : ctx.jsonProvider().getPropertyKeys(model)) {
      handleObjectProperty(currentPath, model, ctx, asList(property));
    }
  } else if (ctx.jsonProvider().isArray(model)) {
    /*
     * Assert.assertNotNull(ctx.getCurrentProperty()); ctx.configuration().jsonProvider().setProperty(curr, ctx.getCurrentProperty(), arrObj);
     * ctx.setLineageParent(arrObj);
     */
    for (int idx = 0; idx < ctx.jsonProvider().length(model); idx++) {
      try {
        handleArrayIndex(idx, currentPath, model, ctx);
      } catch (PathNotFoundException p){
        if(ctx.options().contains(Option.REQUIRE_PROPERTIES)){
          throw p;
        }
      }
    }
  }
}

相关文章