↓ Ir para o conteúdo principal

← todas as notas

📎 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 cast contains Will Smith, then selects their name values.
  • Filters arrays by comparing hi to numeric values, including > 1 and >= 1.
  • Filters a plain numeric array with @ > 1 when 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 $..Name to collect every Name value 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.