Skip to content

Commit 6676bff

Browse files
committed
1 parent b728a84 commit 6676bff

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ Script expressions are not supported as the original author intended because:
107107

108108
So here are the types of query expressions that are supported:
109109

110-
[?(@._KEY_ _OPERATOR_ _VALUE_)] // <, >, !=, ==, in and !in
110+
[?(@._KEY_ _OPERATOR_ _VALUE_)] // <, >, !=, ==, in and nin
111111
Eg.
112112
[?(@.title == "A string")] //
113113
[?(@.title = "A string")]
114114
// A single equals is not an assignment but the SQL-style of '=='
115115
[?(@.title in ["A string", "Another string"])]
116-
[?(@.title !in ["A string", "Another string"])]
116+
[?(@.title nin ["A string", "Another string"])]
117117

118118
Known issues
119119
------

src/Filters/QueryMatchFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class QueryMatchFilter extends AbstractFilter
2020
{
2121
public const MATCH_QUERY_OPERATORS = '
2222
@(\.(?<key>[^ =]+)|\[["\']?(?<keySquare>.*?)["\']?\])
23-
(\s*(?<operator>==|=|<>|!==|!=|>|<|in|!in)\s*(?<comparisonValue>.+))?
23+
(\s*(?<operator>==|=|<>|!==|!=|>|<|in|nin)\s*(?<comparisonValue>.+))?
2424
';
2525

2626
/**
@@ -101,7 +101,7 @@ public function filter($collection): array
101101
$return[] = $value;
102102
}
103103

104-
if ($operator === '!in' && is_array($comparisonValue) && !in_array($value1, $comparisonValue, true)) {
104+
if ($operator === 'nin' && is_array($comparisonValue) && !in_array($value1, $comparisonValue, true)) {
105105
$return[] = $value;
106106
}
107107
}

tests/JSONPathTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,14 @@ public function testQueryMatchIn(): void
277277
}
278278

279279
/**
280-
* $..books[?(@.author not in ["J. R. R. Tolkien", "Nigel Rees"])]
280+
* $..books[?(@.author nin ["J. R. R. Tolkien", "Nigel Rees"])]
281281
* Filter books that don't have a title in ["...", "..."]
282282
*
283283
* @throws Exception
284284
*/
285285
public function testQueryMatchNotIn(): void
286286
{
287-
$result = (new JSONPath($this->exampleData(random_int(0, 1))))->find('$..books[?(@.author !in ["J. R. R. Tolkien", "Nigel Rees"])].title');
287+
$result = (new JSONPath($this->exampleData(random_int(0, 1))))->find('$..books[?(@.author nin ["J. R. R. Tolkien", "Nigel Rees"])].title');
288288

289289
self::assertEquals(['Sword of Honour', 'Moby Dick'], $result->getData());
290290
}

0 commit comments

Comments
 (0)