com.jayway.jsonpath.internal.function.sequence.AbstractSequenceAggregation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-path Show documentation
Show all versions of json-path Show documentation
Java port of Stefan Goessner JsonPath.
package com.jayway.jsonpath.internal.function.sequence;
import com.jayway.jsonpath.JsonPathException;
import com.jayway.jsonpath.internal.EvaluationContext;
import com.jayway.jsonpath.internal.PathRef;
import com.jayway.jsonpath.internal.function.Parameter;
import com.jayway.jsonpath.internal.function.PathFunction;
import java.util.ArrayList;
import java.util.List;
/**
* Defines the pattern for taking item from collection of JSONArray by index
*
* Created by git9527 on 6/11/22.
*/
public abstract class AbstractSequenceAggregation implements PathFunction {
protected abstract int targetIndex(EvaluationContext ctx, List parameters);
@Override
public Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx, List parameters) {
if(ctx.configuration().jsonProvider().isArray(model)){
Iterable> objects = ctx.configuration().jsonProvider().toIterable(model);
List