Skip to content

Latest commit

 

History

History
32 lines (27 loc) · 1.15 KB

StrictEqualsQuery.md

File metadata and controls

32 lines (27 loc) · 1.15 KB

Querying JSON with complex JSON Path

This sample loads JSON and then queries values from it using Argon.JToken.SelectToken(System.String) with a strict equals JSON Path.

var items = JArray.Parse("""
                         [
                           {
                             'Name': 'Valid JSON',
                             'Valid': true
                           },
                           {
                             'Name': 'Invalid JSON',
                             'Valid': 'true'
                           }
                         ]
                         """);

// Use === operator. Compared types must be the same to be valid
var strictResults = items.SelectTokens("$.[?(@.Valid === true)]").ToList();

foreach (var item in strictResults)
{
    Console.WriteLine((string) item["Name"]);
}

// Valid JSON

snippet source | anchor