Filter expression with in current object

Setup

Selector: $[?(2 in @.d)]

[{"d": [1, 2, 3]}, {"d": [2]}, {"d": [1]}, {"d": [3, 4]}, {"d": [4, 2]}]

Results

Other responses

Bash (JSONPath.sh)

[]

C (json-glib)

Not supported

Unable to compile selector `$[?(2 in @.d)]': Invalid array index definition “?(2 in @.d)]”

Clojure (json-path) ¹

[]

Cpp (jsoncons)

Not supported

Expected dot or left bracket separator at line 1 and column 7

Dart (json_path)

Not supported

FormatException: end of input expected at 1:2. Expression: $[?(2 in @.d)]

Elixir (ExJsonPath)

Not supported

syntax error before: 2

Elixir (jaxon)

[]

Elixir (warpath) ¹

Not supported

Parser error: Invalid token on line 1, syntax error before: <<"@">>

Erlang (ejsonpath)

Not supported

syntax error before: <<"in">>

Golang (github.com-PaesslerAG-jsonpath) ¹

Not supported

parsing error: $[?(2 in @.d)]	:1:7 - 1:9 unexpected Ident while scanning parentheses expected ")"

Golang (github.com-ohler55-ojg)

[
  {
    "d": [
      1,
      2,
      3
    ]
  },
  {
    "d": [
      2
    ]
  },
  {
    "d": [
      4,
      2
    ]
  }
]

Golang (github.com-oliveagle-jsonpath) ¹

[]

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

Not supported

invalid filter expression at position 6, following "2 "

Haskell (jsonpath)

Not supported

Invalid JSONPath: $[?(2 in @.d)]
 Error: 1:7:
  |
1 | $[?(2 in @.d)]
  |       ^^
unexpected "in"
expecting "!=", "<=", "==", ">=", '!', '<', '>', or white space

JavaScript (Goessner) ²

[
  {
    "d": [
      1,
      2,
      3
    ]
  }
]

JavaScript (brunerd)

[
  {
    "d": [
      1,
      2,
      3
    ]
  }
]

JavaScript (jsonpath)

[]

JavaScript (jsonpath-plus)

[
  {
    "d": [
      1,
      2,
      3
    ]
  }
]

Java (com.github.jsurfer)

Not supported

line 1:4 no viable alternative at input '2'
org.antlr.v4.runtime.misc.ParseCancellationException

Java (com.jayway.jsonpath) ¹ ³

[
  {
    "d": [
      1,
      2,
      3
    ]
  },
  {
    "d": [
      2
    ]
  },
  {
    "d": [
      4,
      2
    ]
  }
]

Kotlin (com.nfeld.jsonpathkt) ¹

Not supported

Unexpected char, char=?, index=2

Objective-C (SMJJSONPath) ¹ ³

[
  {
    "d": [
      1,
      2,
      3
    ]
  },
  {
    "d": [
      2
    ]
  },
  {
    "d": [
      4,
      2
    ]
  }
]

PHP (galbar-jsonpath) ²

Not found

jsonpath returned false, this might indicate an error

PHP (remorhaz-jsonpath)

Not supported

Error: 'Failed to build AST from JSONPath query: $[?(2 in @.d)]'

Python (jsonpath) ²

[
  {
    "d": [
      1,
      2,
      3
    ]
  },
  {
    "d": [
      2
    ]
  },
  {
    "d": [
      4,
      2
    ]
  }
]

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:6 mismatched input 'in' expecting ')'
ValueError("line 1:6 mismatched input 'in' expecting ')'")

Raku (JSON-Path)

Not supported

Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)

Ruby (jsonpath)

[
  {
    "d": [
      1,
      2,
      3
    ]
  },
  {
    "d": [
      2
    ]
  },
  {
    "d": [
      1
    ]
  },
  {
    "d": [
      3,
      4
    ]
  },
  {
    "d": [
      4,
      2
    ]
  }
]

Rust (jsonpath)

Not supported

parsing error

Rust (jsonpath_lib)

Not supported

path error: 
$[?(2 in @.d)]
^^^^^^

Scala (jsonpath)

Not supported

JPError(end of input expected)

Swift (Sextant)

[
  {
    "d": [
      1,
      2,
      3
    ]
  },
  {
    "d": [
      2
    ]
  },
  {
    "d": [
      4,
      2
    ]
  }
]

dotNET (Json.NET)

Not supported

Could not read query operator.

dotNET (JsonCons.JsonPath)

Not supported

Syntax error

dotNET (JsonPath.Net)

Not supported

Error parsing path index value

dotNET (JsonPathLib)

[
  {
    "d": [
      1,
      2,
      3
    ]
  },
  {
    "d": [
      2
    ]
  },
  {
    "d": [
      1
    ]
  },
  {
    "d": [
      3,
      4
    ]
  },
  {
    "d": [
      4,
      2
    ]
  }
]

dotNET (Manatee.Json)

Not supported

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

JSON (Path_Reference_Implementation)

Not supported

 --> 1:3
  |
1 | $[?(2 in @.d)]
  |   ^---
  |
  = expected unionChild, unionArrayIndex, or sliceStart

Proposal (A)

Not supported


x 1:7-1:7 ComparisonOperator
| $[?(2 in @.d)]
|       ^
x 1:5-1:5 HigherPrecedenceFilterExpression
| $[?(2 in @.d)]
|     ^
| x 1:7-1:7 ComparisonOperator
| | $[?(2 in @.d)]
| |       ^
| x 1:5-1:5 HigherPrecedenceFilterExpression
| | $[?(2 in @.d)]
| |     ^
| x 1:5-1:5 LogicalOr
| | $[?(2 in @.d)]
| |     ^
| | x 1:7-1:7 ComparisonOperator
| | | $[?(2 in @.d)]
| | |       ^
| | x 1:5-1:5 HigherPrecedenceFilterExpression
| | | $[?(2 in @.d)]
| | |     ^
| | x 1:5-1:5 LogicalAnd
| | | $[?(2 in @.d)]
| | |     ^
| | | 
|/ /  
| | 
|/  
x 1:5-1:5 FilterExpression
| $[?(2 in @.d)]
|     ^
x 1:3-1:3 BracketElement
| $[?(2 in @.d)]
|   ^
x 1:3-1:3 BracketElements
| $[?(2 in @.d)]
|   ^
x 1:2-1:2 BracketChildren
| $[?(2 in @.d)]
|  ^
x 1:2-1:2 Operator
| $[?(2 in @.d)]
|  ^
o 1:1-1:2 Start
  $[?(2 in @.d)]
  ^

Errors

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

not enough arguments

Golang (github.com-spyzhov-ajson)

wrong request: wrong request: ?(2 in @.d)

PHP (Goessner) ²

ArgumentCountError

PHP (softcreatr-jsonpath)

Error: 'Malformed filter query'

Perl (JSON-Path)

non-safe evaluation, died at main.pl line 11.

Rust (jsonpath_plus)

Error Parsing JSON Path:
$[?(2 in @.d)]
panic occurred

Footnotes