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

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

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

JsonProvider.setArrayIndex介绍

[英]Sets a value in an array. If the array is too small, the provider is supposed to enlarge it.
[中]设置数组中的值。如果数组太小,提供者应该放大它。

代码示例

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

public void set(Object newVal, Configuration configuration){
  configuration.jsonProvider().setArrayIndex(parent, index, newVal);
}

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

public void addResult(String path, PathRef operation, Object model) {
  if(forUpdate) {
    updateOperations.add(operation);
  }
  configuration.jsonProvider().setArrayIndex(valueResult, resultIndex, model);
  configuration.jsonProvider().setArrayIndex(pathResult, resultIndex, path);
  resultIndex++;
  if(!configuration().getEvaluationListeners().isEmpty()){
    int idx = resultIndex - 1;
    for (EvaluationListener listener : configuration().getEvaluationListeners()) {
      EvaluationListener.EvaluationContinuation continuation = listener.resultFound(new FoundResultImpl(idx, path, model));
      if(EvaluationListener.EvaluationContinuation.ABORT == continuation){
        throw ABORT_EVALUATION;
      }
    }
  }
}

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

@Override
  public Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx, List<Parameter> parameters) {
    JsonProvider jsonProvider = ctx.configuration().jsonProvider();
    if (parameters != null && parameters.size() > 0) {
      for (Parameter param : parameters) {
        if (jsonProvider.isArray(model)) {
          int len = jsonProvider.length(model);
          jsonProvider.setArrayIndex(model, len, param.getValue());
        }
      }
    }
    return model;
  }
}

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

public void convert(MapFunction mapFunction, Configuration configuration){
  Object currentValue = configuration.jsonProvider().getArrayIndex(parent, index);
  configuration.jsonProvider().setArrayIndex(parent, index, mapFunction.map(currentValue, configuration));
}

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

@Override
public void add(Object newVal, Configuration configuration) {
  if(configuration.jsonProvider().isArray(parent)){
    configuration.jsonProvider().setArrayIndex(parent, configuration.jsonProvider().length(parent), newVal);
  } else {
    throw new InvalidModificationException("Invalid add operation. $ is not an array");
  }
}

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

public void add(Object value, Configuration configuration){
  Object target = configuration.jsonProvider().getMapValue(parent, property);
  if(targetInvalid(target)){
    return;
  }
  if(configuration.jsonProvider().isArray(target)){
    configuration.jsonProvider().setArrayIndex(target, configuration.jsonProvider().length(target), value);
  } else {
    throw new InvalidModificationException("Can only add to an array");
  }
}

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

public void set(Object newVal, Configuration configuration){
  configuration.jsonProvider().setArrayIndex(parent, index, newVal);
}

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

if (optAlwaysReturnList && path.isDefinite()) {
  Object array = configuration.jsonProvider().createArray();
  configuration.jsonProvider().setArrayIndex(array, 0, res);
  return (T) array;
} else {

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

public void addResult(String path, PathRef operation, Object model) {
  if(forUpdate) {
    updateOperations.add(operation);
  }
  configuration.jsonProvider().setArrayIndex(valueResult, resultIndex, model);
  configuration.jsonProvider().setArrayIndex(pathResult, resultIndex, path);
  resultIndex++;
  if(!configuration().getEvaluationListeners().isEmpty()){
    int idx = resultIndex - 1;
    for (EvaluationListener listener : configuration().getEvaluationListeners()) {
      EvaluationListener.EvaluationContinuation continuation = listener.resultFound(new FoundResultImpl(idx, path, model));
      if(EvaluationListener.EvaluationContinuation.ABORT == continuation){
        throw ABORT_EVALUATION;
      }
    }
  }
}

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

public void convert(MapFunction mapFunction, Configuration configuration){
  Object currentValue = configuration.jsonProvider().getArrayIndex(parent, index);
  configuration.jsonProvider().setArrayIndex(parent, index, mapFunction.map(currentValue, configuration));
}

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

@Override
  public Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx, List<Parameter> parameters) {
    JsonProvider jsonProvider = ctx.configuration().jsonProvider();
    if (parameters != null && parameters.size() > 0) {
      for (Parameter param : parameters) {
        if (jsonProvider.isArray(model)) {
          int len = jsonProvider.length(model);
          jsonProvider.setArrayIndex(model, len, param.getValue());
        }
      }
    }
    return model;
  }
}

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

@Override
public void add(Object newVal, Configuration configuration) {
  if(configuration.jsonProvider().isArray(parent)){
    configuration.jsonProvider().setArrayIndex(parent, configuration.jsonProvider().length(parent), newVal);
  } else {
    throw new InvalidModificationException("Invalid add operation. $ is not an array");
  }
}

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

public void add(Object value, Configuration configuration){
  Object target = configuration.jsonProvider().getMapValue(parent, property);
  if(targetInvalid(target)){
    return;
  }
  if(configuration.jsonProvider().isArray(target)){
    configuration.jsonProvider().setArrayIndex(target, configuration.jsonProvider().length(target), value);
  } else {
    throw new InvalidModificationException("Can only add to an array");
  }
}

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

public void set(Object newVal, Configuration configuration){
  configuration.jsonProvider().setArrayIndex(parent, index, newVal);
}

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

if (optAlwaysReturnList && path.isDefinite()) {
  Object array = configuration.jsonProvider().createArray();
  configuration.jsonProvider().setArrayIndex(array, 0, res);
  return (T) array;
} else {

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

private void checkAndFillArrayElements(EvaluationContextImpl ctx, Object parent, Object evalHit, int effectiveIndex) {
  Object copy = ctx.jsonProvider().copy(evalHit);
  int len = ctx.jsonProvider().length(parent);
  // fill dummy array elements
  if (len < effectiveIndex) {
    for (int i = len; i < effectiveIndex; i++) {
      ctx.jsonProvider().setArrayIndex(parent, i, copy);
    }
  }
  ctx.jsonProvider().setArrayIndex(ctx.getParent(), effectiveIndex, evalHit);
}

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

@Override
  public Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx, List<Parameter> parameters) {
    JsonProvider jsonProvider = ctx.configuration().jsonProvider();
    if (parameters != null && parameters.size() > 0) {
      for (Parameter param : parameters) {
        if (jsonProvider.isArray(model)) {
          int len = jsonProvider.length(model);
          jsonProvider.setArrayIndex(model, len, param.getValue());
        }
      }
    }
    return model;
  }
}

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

public void convert(MapFunction mapFunction, Configuration configuration){
  Object currentValue = configuration.jsonProvider().getArrayIndex(parent, index);
  configuration.jsonProvider().setArrayIndex(parent, index, mapFunction.map(currentValue, configuration));
}

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

@Override
public void add(Object newVal, Configuration configuration) {
  if(configuration.jsonProvider().isArray(parent)){
    configuration.jsonProvider().setArrayIndex(parent, configuration.jsonProvider().length(parent), newVal);
  } else {
    throw new InvalidModificationException("Invalid add operation. $ is not an array");
  }
}

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

public void add(Object value, Configuration configuration){
  Object target = configuration.jsonProvider().getMapValue(parent, property);
  if(targetInvalid(target)){
    return;
  }
  if(configuration.jsonProvider().isArray(target)){
    configuration.jsonProvider().setArrayIndex(target, configuration.jsonProvider().length(target), value);
  } else {
    throw new InvalidModificationException("Can only add to an array");
  }
}

相关文章