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

FormatException: end of input expected at 1:2. Expression: $[?(@.name=~/hello.*/)]

Elixir (ExJsonPath)

Not supported

illegal characters "=~"

Elixir (jaxon)

[]

Elixir (warpath) ¹

Not supported

Invalid syntax on line 1, {:illegal, '=~'}

Golang (github.com-AsaiYusuke-jsonpath) ²

[
  {
    "name": "hello world"
  },
  {
    "name": "yes hello world"
  }
]

Golang (github.com-PaesslerAG-jsonpath) ¹

Not supported

parsing error: $[?(@.name=~/hello.*/)]	 - 1:13 unknown operator =~

Golang (github.com-bhmj-jsonslice) ¹ ³

[
  {
    "name": "hello world"
  },
  {
    "name": "yes hello world"
  }
]

Golang (github.com-ohler55-ojg)

Not supported

Golang (github.com-oliveagle-jsonpath) ¹

[]

Golang (github.com-vmware-labs-yaml-jsonpath)

[
  {
    "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
  }
]

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: '~'")

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.*/)]
^^^^^^^^^^

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 (Manatee.Json)

Not supported

Unrecognized JSON Path Expression element. Path up to error: '$'

JSON (Path_Reference_Implementation)

Not supported

 --> 1:3
  |
1 | $[?(@.name=~/hello.*/)]
  |   ^---
  |
  = expected unionChild, unionArrayIndex, or sliceStart

Proposal (A)

Not supported


x 1:11-1:11 ComparisonOperator
| $[?(@.name=~/hello.*/)]
|           ^
| x 1:11-1:11 ScalarOperator
| | $[?(@.name=~/hello.*/)]
| |           ^
| o 1:5-1:11 DocumentValue
| | $[?(@.name=~/hello.*/)]
| |     ^^^^^^
| o 1:5-1:11 UnaryFilterExpression
| | $[?(@.name=~/hello.*/)]
| |     ^^^^^^
| | x 1:11-1:11 ScalarOperator
| | | $[?(@.name=~/hello.*/)]
| | |           ^
| | o 1:5-1:11 DocumentValue
| | | $[?(@.name=~/hello.*/)]
| | |     ^^^^^^
| | o 1:5-1:11 FilterValue
| | | $[?(@.name=~/hello.*/)]
| | |     ^^^^^^
| | | 
|/ /  
| | 
|/  
o 1:5-1:11 HigherPrecedenceFilterExpression
| $[?(@.name=~/hello.*/)]
|     ^^^^^^
x 1:5-1:5 LogicalOr
| $[?(@.name=~/hello.*/)]
|     ^
| x 1:11-1:11 ComparisonOperator
| | $[?(@.name=~/hello.*/)]
| |           ^
| | x 1:11-1:11 ScalarOperator
| | | $[?(@.name=~/hello.*/)]
| | |           ^
| | o 1:5-1:11 DocumentValue
| | | $[?(@.name=~/hello.*/)]
| | |     ^^^^^^
| | o 1:5-1:11 UnaryFilterExpression
| | | $[?(@.name=~/hello.*/)]
| | |     ^^^^^^
| | | x 1:11-1:11 ScalarOperator
| | | | $[?(@.name=~/hello.*/)]
| | | |           ^
| | | o 1:5-1:11 DocumentValue
| | | | $[?(@.name=~/hello.*/)]
| | | |     ^^^^^^
| | | o 1:5-1:11 FilterValue
| | | | $[?(@.name=~/hello.*/)]
| | | |     ^^^^^^
| | | | 
| |/ /  
| | | 
| |/  
| o 1:5-1:11 HigherPrecedenceFilterExpression
| | $[?(@.name=~/hello.*/)]
| |     ^^^^^^
| x 1:5-1:5 LogicalAnd
| | $[?(@.name=~/hello.*/)]
| |     ^
| | x 1:11-1:11 ComparisonOperator
| | | $[?(@.name=~/hello.*/)]
| | |           ^
| | | x 1:11-1:11 ScalarOperator
| | | | $[?(@.name=~/hello.*/)]
| | | |           ^
| | | o 1:5-1:11 DocumentValue
| | | | $[?(@.name=~/hello.*/)]
| | | |     ^^^^^^
| | | o 1:5-1:11 UnaryFilterExpression
| | | | $[?(@.name=~/hello.*/)]
| | | |     ^^^^^^
| | | | x 1:11-1:11 ScalarOperator
| | | | | $[?(@.name=~/hello.*/)]
| | | | |           ^
| | | | o 1:5-1:11 DocumentValue
| | | | | $[?(@.name=~/hello.*/)]
| | | | |     ^^^^^^
| | | | o 1:5-1:11 FilterValue
| | | | | $[?(@.name=~/hello.*/)]
| | | | |     ^^^^^^
| | | | | 
| | |/ /  
| | | | 
| | |/  
| | o 1:5-1:11 HigherPrecedenceFilterExpression
| | | $[?(@.name=~/hello.*/)]
| | |     ^^^^^^
| | | 
|/ /  
| | 
|/  
o 1:5-1:11 FilterExpression
| $[?(@.name=~/hello.*/)]
|     ^^^^^^
x 1:3-1:3 BracketElement
| $[?(@.name=~/hello.*/)]
|   ^
x 1:3-1:3 BracketElements
| $[?(@.name=~/hello.*/)]
|   ^
x 1:2-1:2 BracketChildren
| $[?(@.name=~/hello.*/)]
|  ^
x 1:2-1:2 Operator
| $[?(@.name=~/hello.*/)]
|  ^
o 1:1-1:2 Start
  $[?(@.name=~/hello.*/)]
  ^

Errors

Erlang (ejsonpath)

Timeout

Golang (github.com-spyzhov-ajson)

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

dotNET (JsonPathLib)

Object of type 'System.Double' cannot be converted to type 'Newtonsoft.Json.Linq.JToken'.

Footnotes