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

  1. Use only supported operators: == != < <= > >= =~ in / nin / size / empty (case-insensitive for the word operators).
  2. Check the message text for the exact unsupported token and correct the spelling (e.g. "=~" for regex match, not "~~").
  3. Replace JavaScript-style strict equality ("===") with "==".
  4. 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

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


AI-assisted analysis of json-path/JsonPath@62a4c9f0f6 (2026-09-11). Data as JSON: /api/errors/55703e67f3012058. Report an issue: GitHub.