Filter expression with in array of values
Setup
Selector: $[?(@.d in [2, 3])]
[{"d": 1}, {"d": 2}, {"d": 1}, {"d": 3}, {"d": 4}]
Results
Consensus
Not supported
Other responses
Bash (JSONPath.sh)
[]
Elixir (jaxon)
[]
Elixir (warpath)
¹
[
{
"d": 2
},
{
"d": 3
}
]
[]
[
{
"d": 2
},
{
"d": 3
}
]
JavaScript (Goessner)
²
[
{
"d": 1
},
{
"d": 1
}
]
JavaScript (brunerd)
[
{
"d": 1
},
{
"d": 2
},
{
"d": 1
},
{
"d": 3
},
{
"d": 4
}
]
JavaScript (jsonpath)
[]
JavaScript (jsonpath-plus)
[
{
"d": 1
},
{
"d": 1
}
]
Java (com.jayway.jsonpath)
¹
³
[
{
"d": 2
},
{
"d": 3
}
]
Objective-C (SMJJSONPath)
¹
³
[
{
"d": 2
},
{
"d": 3
}
]
PHP (softcreatr-jsonpath)
[
{
"d": 2
},
{
"d": 3
}
]
Python (jsonpath)
²
[
{
"d": 2
},
{
"d": 3
}
]
Swift (Sextant)
[
{
"d": 2
},
{
"d": 3
}
]
dotNET (JsonPathLib)
[
{
"d": 1
},
{
"d": 1
}
]
Errors
Clojure (json-path)
¹
java.lang.Exception object must be an array.
interface conversion: interface {} is nil, not string
wrong request: wrong request: ?(@.d in [2, 3])
PHP (Goessner)
²
ArgumentCountError
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
Ruby (jsonpath)
invalid value for Integer(): " 3])"
Rust (jsonpath_plus)
Error Parsing JSON Path:
$[?(@.d in [2, 3])]
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.