json-path/JsonPath · error · InvalidPathException
Filter operator is not supported!
Error message
Filter operator is not supported!
What it means
RelationalOperator.fromString() uppercases the given token and looks for a matching RelationalOperator enum (e.g. ==, !=, <, >, =~, IN, NIN, SIZE, EMPTY). If no enum constant's operatorString equals it, the library throws InvalidPathException stating the filter operator is not supported. The lookup is case-insensitive, so the token must still be a known operator after uppercasing.
Source
Thrown at json-path/src/main/java/com/jayway/jsonpath/internal/filter/RelationalOperator.java:52
EMPTY("EMPTY"),
SUBSETOF("SUBSETOF"),
ANYOF("ANYOF"),
NONEOF("NONEOF");
private final String operatorString;
RelationalOperator(String operatorString) {
this.operatorString = operatorString;
}
public static RelationalOperator fromString(String operatorString) {
String upperCaseOperatorString = operatorString.toUpperCase(Locale.ROOT);
for (RelationalOperator operator : RelationalOperator.values()) {
if(operator.operatorString.equals(upperCaseOperatorString) ){
return operator;
}
}
throw new InvalidPathException("Filter operator " + operatorString + " is not supported!");
}
@Override
public String toString() {
return operatorString;
}
}
View on GitHub (pinned to 62a4c9f0f6)
Solutions
- Use only supported operators: == != < <= > >= =~ in / nin / size / empty (case-insensitive for the word operators).
- Check the message text for the exact unsupported token and correct the spelling (e.g. "=~" for regex match, not "~~").
- Replace JavaScript-style strict equality ("===") with "==".
- Validate filter expressions at load time in a test so invalid operators fail fast before runtime evaluation.
Example fix
// before String jsonPath = "$[?(@.name === 'foo')]"; JsonPath.read(json, jsonPath); // after String jsonPath = "$[?(@.name == 'foo')]"; JsonPath.read(json, jsonPath);
Defensive patterns
Strategy: validation
Validate before calling
// Java: check each predicate operator against the supported set before evaluating
static final java.util.Set<String> SUPPORTED = java.util.Set.of(
"==","!=","<","<=",">",">=","=~","IN","NIN","SIZE","EMPTY","ALL","ANY","NONE","MATCHES");
void validateOperators(String filter) {
for (String tok : filter.split("\\s+")) {
if (!SUPPORTED.contains(tok.toUpperCase(java.util.Locale.ROOT)) && !tok.matches("[@$.(].*") && !tok.startsWith("&&") && !tok.startsWith("||")) {
// log/inspect suspicious tokens; cheaper than a runtime parse failure
}
}
} Try / catch
try {
return JsonPath.read(json, path);
} catch (InvalidPathException e) {
if (e.getMessage().contains("is not supported!")) {
throw new IllegalArgumentException("Unsupported filter operator in: " + path, e);
}
throw e;
} Prevention
- Memorize the supported set: == != < <= > >= =~ in nin size empty (word operators case-insensitive).
- Never use JS-style === or !==; Jayway only has ==.
- Use =~ for regex matching, not ~~.
- Parse all configured paths once at boot in a fail-fast test.
When it happens
Trigger: Calling JsonPath.read/parse with a filter predicate using a comparison operator not in RelationalOperator (e.g. "===", "=<", ">>", or a locale-specific symbol) — the uppercase form of the token matches no enum constant.
Common situations: Filters ported from other JSONPath engines or SQL/JS habits ("===", "!=="); regex comparisons written as "~~" instead of "=~"; typos like "=<"; expressions generated by tooling that emits a non-Jayway operator set.
Related errors
- Failed to parse operator
- Filter must start with '[' and end with ']'.
- Filter must start with '[?' and end with ']'.
- Filter must start with '[?(' and end with ')]'.
- Could not find matching close quote for %s when parsing : %s
AI-assisted analysis of json-path/JsonPath@62a4c9f0f6 (2026-09-11).
Data as JSON: /api/errors/55703e67f3012058.
Report an issue: GitHub.