Filter expression with boolean or operator and value true

Setup

Selector: $[?(@.key>0 || true)]

[
  {"key": 1},
  {"key": 3},
  {"key": "nice"},
  {"key": true},
  {"key": null},
  {"key": false},
  {"key": {}},
  {"key": []},
  {"key": -1},
  {"key": 0},
  {"key": ""}
]

Results

Other responses

Bash (JSONPath.sh)

[
  1,
  3,
  true,
  null,
  false
]

C (json-glib)

Not supported

Unable to compile selector `$[?(@.key>0 || true)]': Invalid array index definition “?(@.key>0 || true)]”

Clojure (json-path) ¹

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

Cpp (jsoncons)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

Dart (json_path)

Not supported

FormatException: end of input expected at 1:2. Expression: $[?(@.key>0 || true)]

Elixir (ExJsonPath)

Not supported

illegal characters "|"

Elixir (jaxon)

[]

Elixir (warpath) ¹

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

Golang (github.com-PaesslerAG-jsonpath) ¹

Not supported

parsing error: $[?(@.key>0 || true)]	:1:10 - 1:11 unexpected ">" while scanning parentheses expected ")"

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

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

Golang (github.com-ohler55-ojg)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

Golang (github.com-oliveagle-jsonpath) ¹

[]

Golang (github.com-spyzhov-ajson)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

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

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

Haskell (jsonpath)

Not supported

Invalid JSONPath: $[?(@.key>0 || true)]
 Error: 1:20:
  |
1 | $[?(@.key>0 || true)]
  |                    ^^
unexpected ")]"
expecting "!=", "<=", "==", ">=", '!', '<', '>', or white space

JavaScript (Goessner) ²

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

JavaScript (brunerd)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

JavaScript (jsonpath)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

JavaScript (jsonpath-plus)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

Java (com.github.jsurfer)

Not supported

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

Java (com.jayway.jsonpath) ¹ ³

Not supported

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
com.jayway.jsonpath.InvalidPathException: Expected path node

Kotlin (com.nfeld.jsonpathkt) ¹

Not supported

Unexpected char, char=?, index=2

Objective-C (SMJJSONPath) ¹ ³

Not supported

Expected character ')' but found '|'

PHP (galbar-jsonpath) ²

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": []
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

PHP (remorhaz-jsonpath)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

PHP (softcreatr-jsonpath)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": {}
  },
  {
    "key": []
  }
]

Python (jsonpath) ²

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": true
  }
]

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:12 token recognition error at: '|'
ValueError("line 1:12 token recognition error at: '|'")

Raku (JSON-Path)

Not supported

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

Rust (jsonpath)

Not supported

parsing error

Rust (jsonpath_lib)

Not supported

path error: 
$[?(@.key>0 || true)]
^^^^^^^^^^^^^^^^^^^

Rust (jsonpath_plus)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": -1
  },
  {
    "key": 0
  }
]

Scala (jsonpath)

Not supported

JPError(end of input expected)

Swift (Sextant)

Not supported

NOT_SUPPORTED

dotNET (JsonCons.JsonPath)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

dotNET (JsonPath.Net)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": -1
  },
  {
    "key": 0
  }
]

dotNET (JsonPathLib)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

dotNET (Manatee.Json)

[
  {
    "key": 1
  },
  {
    "key": 3
  },
  {
    "key": "nice"
  },
  {
    "key": true
  },
  {
    "key": null
  },
  {
    "key": false
  },
  {
    "key": {}
  },
  {
    "key": []
  },
  {
    "key": -1
  },
  {
    "key": 0
  },
  {
    "key": ""
  }
]

JSON (Path_Reference_Implementation)

Not supported

 --> 1:3
  |
1 | $[?(@.key>0 || true)]
  |   ^---
  |
  = expected unionChild, unionArrayIndex, or sliceStart

Proposal (A)

Not supported


x 1:20-1:20 ComparisonOperator
| $[?(@.key>0 || true)]
|                    ^
x 1:16-1:16 HigherPrecedenceFilterExpression
| $[?(@.key>0 || true)]
|                ^
| x 1:20-1:20 ComparisonOperator
| | $[?(@.key>0 || true)]
| |                    ^
| x 1:16-1:16 HigherPrecedenceFilterExpression
| | $[?(@.key>0 || true)]
| |                ^
| x 1:16-1:16 LogicalOr
| | $[?(@.key>0 || true)]
| |                ^
| | 
|/  
x 1:5-1:5 LogicalOr
| $[?(@.key>0 || true)]
|     ^
o 1:5-1:12 FilterExpression
| $[?(@.key>0 || true)]
|     ^^^^^^^
x 1:3-1:3 BracketElement
| $[?(@.key>0 || true)]
|   ^
x 1:3-1:3 BracketElements
| $[?(@.key>0 || true)]
|   ^
x 1:2-1:2 BracketChildren
| $[?(@.key>0 || true)]
|  ^
x 1:2-1:2 Operator
| $[?(@.key>0 || true)]
|  ^
o 1:1-1:2 Start
  $[?(@.key>0 || true)]
  ^

Errors

Erlang (ejsonpath)

Timeout

PHP (Goessner) ²

ArgumentCountError

Perl (JSON-Path)

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

Ruby (jsonpath)

comparison of String with 0.0 failed

dotNET (Json.NET)

Input string was not in a correct format.

Footnotes