public class JsonPathExpression extends Object
JsonPath expression.| Modifier and Type | Field and Description |
|---|---|
static JsonPathExpression |
ROOT
A pre-compiled
JsonPathExpression that represents the root element of a JSON
document ('$'). |
| Constructor and Description |
|---|
JsonPathExpression(String expression)
Creates a compiled
JsonPathExpression from the specified expression. |
| Modifier and Type | Method and Description |
|---|---|
JsonPathExpression |
append(String expression)
Produces a new
JsonPathExpression with the concatenation result of this
JsonPathExpression and the given expression. |
JsonPathExpression |
appendChild(String name)
Produces a new
JsonPathExpression with the concatenation result of this
JsonPathExpression and the given child element name. |
JsonPathExpression |
appendIndex(int index)
Produces a new
JsonPathExpression with the concatenation result of this
JsonPathExpression and a given index. |
JsonPathExpression |
cleanUp()
Performs a cleanup of the path associated with this
JsonPathExpression. |
boolean |
equals(Object other) |
int |
hashCode() |
String |
toString()
Returns the string representation of this
JsonPathExpression, in the
bracket-notation. |
public static final JsonPathExpression ROOT
JsonPathExpression that represents the root element of a JSON
document ('$').public JsonPathExpression(String expression)
JsonPathExpression from the specified expression.expression - the JsonPath expression to compileIllegalArgumentException - if the specified expression is null or emptycom.jayway.jsonpath.InvalidPathException - if the specified JsonPath expression is invalidpublic JsonPathExpression appendChild(String name)
JsonPathExpression with the concatenation result of this
JsonPathExpression and the given child element name.name - the child name to be appended to the end of this JsonPathExpressionJsonPathExpressioncom.jayway.jsonpath.InvalidPathException - if the resulting JsonPath expression is invalidpublic JsonPathExpression appendIndex(int index)
JsonPathExpression with the concatenation result of this
JsonPathExpression and a given index.index - the index to be appended to the end of this JsonPathExpressionJsonPathExpressioncom.jayway.jsonpath.InvalidPathException - if the resulting JsonPath expression is invalidpublic JsonPathExpression append(String expression)
JsonPathExpression with the concatenation result of this
JsonPathExpression and the given expression.expression - a String representing the expression to be appended to the
end of this JsonPathExpressionJsonPathExpressioncom.jayway.jsonpath.InvalidPathException - if the resulting JsonPath expression is invalidpublic JsonPathExpression cleanUp()
JsonPathExpression.
During cleanup, arrays indexes are replaced with a wildcard character (*).
For example:
new JsonPathExpression("$['foo'][0]['bar'][1]").cleanup(); // returns: $['foo'][*]['bar'][*]
JsonPathExpression from the cleanup of this onepublic String toString()
JsonPathExpression, in the
bracket-notation. For example: $['store']['book'][0]['title']Copyright © 2025. All rights reserved.