📎 Webclip
JArray.SelectTokens Examples
The page collects 12 C# examples of Newtonsoft.Json.Linq.JArray.SelectTokens. The examples show how the method returns matching tokens from arrays when the query uses nested conditions, recursive scans, wildcards, slices, multiple indexes, and comparisons on numeric and string values.
Reading notes#
- Uses a nested filter to find array items whose
castcontainsWill Smith, then selects theirnamevalues. - Filters arrays by comparing
hito numeric values, including> 1and>= 1. - Filters a plain numeric array with
@ > 1when no path is present. - Shows that chained JSONPath filters can return no results when the first filter reduces items to scalars.
- Uses
$..*to scan and return the array, objects, nested objects, arrays, and primitive values in traversal order. - Uses
$..Nameto collect everyNamevalue in the array. - Uses
[*]to return all array elements. - Uses
[1,2,0]to return selected array items in the listed order. - Uses slices such as
[-3:],[-1:-2:-1],[-2:-1],[1:1],[1:2],[::-1], and[::-2]to select ranges and reverse order.
