-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deployed 39ee4cf with MkDocs version: 1.4.3
- Loading branch information
Showing
8 changed files
with
255 additions
and
58 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -827,30 +827,33 @@ <h3 id="recursive-descent">Recursive descent (<code>..</code>)</h3> | |
<div class="language-text highlight"><pre><span></span><code><span id="__span-17-1"><a id="__codelineno-17-1" name="__codelineno-17-1" href="#__codelineno-17-1"></a>$...title | ||
</span></code></pre></div> | ||
<h3 id="filters-expression">Filters (<code>[?EXPRESSION]</code>)</h3> | ||
<p>Filters allow you to remove nodes from a selection using a Boolean expression. When filtering a mapping-like object, <code>#</code> references the current key/property and <code>@</code> references the current value associated with <code>#</code>. When filtering a sequence-like object, <code>@</code> references the current item and <code>#</code> will hold the item's index in the sequence.</p> | ||
<p>Filters allow you to remove nodes from a selection using a Boolean expression. A <em>filter query</em> is a JSONPath query nested within a filter expression. Every filter query must start with the root identifier (<code>$</code>), the current node identifier (<code>@</code>) or the <a href="../advanced/#filter-variables">filter context</a> identifier (<code>_</code>).</p> | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-18-1"><a id="__codelineno-18-1" name="__codelineno-18-1" href="#__codelineno-18-1"></a>$..products[?(@.price < $.price_cap)] | ||
</span></code></pre></div> | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-19-1"><a id="__codelineno-19-1" name="__codelineno-19-1" href="#__codelineno-19-1"></a>$..products[[email protected] < $.price_cap] | ||
</span></code></pre></div> | ||
<p>When filtering a mapping-like object, <code>#</code> references the current key/property and <code>@</code> references the current value associated with <code>#</code>. When filtering a sequence-like object, <code>@</code> references the current item and <code>#</code> will hold the item's index in the sequence.</p> | ||
<p>Comparison operators include <code>==</code>, <code>!=</code>, <code><</code>, <code>></code>, <code><=</code> and <code>>=</code>. Plus <code><></code> as an alias for <code>!=</code>.</p> | ||
<p><code>in</code> and <code>contains</code> are membership operators. <code>left in right</code> is equivalent to <code>right contains left</code>.</p> | ||
<p><code>&&</code> and <code>||</code> are logical operators, <code>and</code> and <code>or</code> work too.</p> | ||
<p><code>&&</code> and <code>||</code> are logical operators and terms can be grouped with parentheses. <code>and</code> and <code>or</code> work too.</p> | ||
<p><code>=~</code> matches the left value with a regular expression literal. Regular expressions use a syntax similar to that found in JavaScript, where the pattern to match is surrounded by slashes, optionally followed by flags.</p> | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-20-1"><a id="__codelineno-20-1" name="__codelineno-20-1" href="#__codelineno-20-1"></a>$..products[?(@.description =~ /.*trainers/i)] | ||
</span></code></pre></div> | ||
<p>Filter expressions can call predefined <a href="../functions/">function extensions</a> too.</p> | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-21-1"><a id="__codelineno-21-1" name="__codelineno-21-1" href="#__codelineno-21-1"></a>$.categories[?count(@.products.*) >= 2] | ||
<p>A filter query on its own - one that is not part of a comparison expression - is an existence test. We also support comparing a filter query to the special <code>undefined</code> keyword. These two example are equivalent.</p> | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-21-1"><a id="__codelineno-21-1" name="__codelineno-21-1" href="#__codelineno-21-1"></a>$..products[[email protected]_price] | ||
</span></code></pre></div> | ||
<p><code>undefined</code> can be used to filter on the absence of a key/property or an undefined value returned from a filter function. <code>missing</code> is an alias for <code>undefined</code>.</p> | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-22-1"><a id="__codelineno-22-1" name="__codelineno-22-1" href="#__codelineno-22-1"></a>$..products[[email protected]_price == undefined] | ||
</span></code></pre></div> | ||
<p>Filter expressions can call predefined <a href="../functions/">function extensions</a> too.</p> | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-23-1"><a id="__codelineno-23-1" name="__codelineno-23-1" href="#__codelineno-23-1"></a>$.categories[?count(@.products.*) >= 2] | ||
</span></code></pre></div> | ||
<h3 id="union-and-intersection">Union (<code>|</code>) and intersection (<code>&</code>)</h3> | ||
<p>Union (<code>|</code>) and intersection (<code>&</code>) are similar to Python's set operations, but we don't dedupe the matches (matches will often contain unhashable objects).</p> | ||
<p>The <code>|</code> operator combines matches from two or more paths. This example selects a single list of all prices, plus the price cap as the last element.</p> | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-23-1"><a id="__codelineno-23-1" name="__codelineno-23-1" href="#__codelineno-23-1"></a>$..products.*.price | $.price_cap | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-24-1"><a id="__codelineno-24-1" name="__codelineno-24-1" href="#__codelineno-24-1"></a>$..products.*.price | $.price_cap | ||
</span></code></pre></div> | ||
<p>The <code>&</code> operator produces matches that are common to both left and right paths. This example would select the list of products that are common to both the "footwear" and "headwear" categories.</p> | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-24-1"><a id="__codelineno-24-1" name="__codelineno-24-1" href="#__codelineno-24-1"></a>$.categories[?(@.name == 'footwear')].products.* & $.categories[?(@.name == 'headwear')].products.* | ||
<div class="language-text highlight"><pre><span></span><code><span id="__span-25-1"><a id="__codelineno-25-1" name="__codelineno-25-1" href="#__codelineno-25-1"></a>$.categories[?(@.name == 'footwear')].products.* & $.categories[?(@.name == 'headwear')].products.* | ||
</span></code></pre></div> | ||
<p>Note that <code>|</code> and <code>&</code> are not allowed inside filter expressions.</p> | ||
<h2 id="notable-differences">Notable differences</h2> | ||
|