Filter expression with regular expression
Setup
Selector: $[?(@.name=~/hello.*/)]
[
{"name": "hullo world"},
{"name": "hello world"},
{"name": "yes hello world"},
{"name": "HELLO WORLD"},
{"name": "good bye"}
]
Results
Other responses
Bash (JSONPath.sh)
[]
C (json-glib)
Not supported
Unable to compile selector `$[?(@.name=~/hello.*/)]': Invalid array index definition “?(@.name=~/hello.*/)]”
Clojure (json-path)
¹
[]
Cpp (jsoncons)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
Dart (json_path)
Not supported
Instance of 'ParserException': end of input expected (at 1:2)
Elixir (ExJsonPath)
Not supported
illegal characters "=~"
Elixir (jaxon)
[]
Elixir (warpath)
¹
Not supported
Invalid syntax on line 1, {:illegal, '=~'}
Not supported
parsing error: $[?(@.name=~/hello.*/)] - 1:13 unknown operator =~
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
Not supported
[]
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
Haskell (jsonpath)
Not supported
Invalid JSONPath: $[?(@.name=~/hello.*/)]
Error: 1:11:
|
1 | $[?(@.name=~/hello.*/)]
| ^
unexpected '='
expecting "!=", "&&", "<=", "==", ">=", "||", '!', ')', '.', '<', '>', '[', or white space
JavaScript (Goessner)
²
[
{
"name": -1
},
{
"name": -1
},
{
"name": -1
},
{
"name": -1
},
{
"name": -1
}
]
JavaScript (brunerd)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
JavaScript (jsonpath)
[]
JavaScript (jsonpath-plus)
[
{
"name": -1
},
{
"name": -1
},
{
"name": -1
},
{
"name": -1
},
{
"name": -1
}
]
JavaScript (jsonpathly)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
Java (com.github.jsurfer)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
Java (com.jayway.jsonpath)
¹
³
[
{
"name": "hello world"
}
]
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
Objective-C (SMJJSONPath)
¹
³
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
PHP (galbar-jsonpath)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
PHP (remorhaz-jsonpath)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
PHP (softcreatr-jsonpath)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
Python (jsonpath)
²
Not found
jsonpath returned false, this might indicate an error
Python (jsonpath-ng)
Not supported
JsonPathLexerError('Error on line 1, col 2: Unexpected character: ? ')
Python (jsonpath-rw)
Not supported
JsonPathLexerError('Error on line 1, col 2: Unexpected character: ? ')
Python (jsonpath2)
Not supported
line 1:11 token recognition error at: '~'
ValueError("line 1:11 token recognition error at: '~'")
Python (python-jsonpath)
[
{
"name": "hello world"
}
]
Raku (JSON-Path)
Not supported
Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)
Ruby (jsonpath)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
Rust (jsonpath)
Not supported
parsing error
Rust (jsonpath_lib)
Not supported
path error:
$[?(@.name=~/hello.*/)]
^^^^^^^^^^
Rust (serde_json_path)
Not supported
at position 3, in long-hand segment, parser error
Scala (jsonpath)
Not supported
JPError(end of input expected)
Swift (Sextant)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
dotNET (Json.NET)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
dotNET (JsonCons.JsonPath)
[
{
"name": "hello world"
},
{
"name": "yes hello world"
}
]
dotNET (JsonPath.Net)
Not supported
Pattern '(@.name=~/...' not recognized.
dotNET (JsonPathLib)
[
{
"name": -1.0
},
{
"name": -1.0
},
{
"name": -1.0
},
{
"name": -1.0
},
{
"name": -1.0
}
]
dotNET (Manatee.Json)
Not supported
Unrecognized JSON Path Expression element. Path up to error: '$'
Errors
Erlang (ejsonpath)
Timeout
wrong request: wrong request: ?(@.name=~/hello.*/)
PHP (Goessner)
²
ArgumentCountError
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
Rust (jsonpath_plus)
Error Parsing JSON Path:
$[?(@.name=~/hello.*/)]
panic occurred
Footnotes
- ¹ This implementation returns a single value where only one match is possible (instead of an array of a single value).
- ² This implementation returns a specific not found value if no match exists.
- ³ This implementation returns a specific not found value if a query that would regularly return a single match results in no match.