c# jsonpath
C# JSONPath Evaluator
Test JSONPath expressions online and generate C# code examples to query JSON. Copy results, debug errors, iterate fast.
Example: $.store.book[*].title
$
Input JSON
Live evaluation (300ms)Result
JSON array of matches[ "Sayings of the Century", "Sword of Honour", "Moby Dick" ]
Generate Code
// dotnet add package JsonPath.Net
using Json.Path;
using System.Text.Json;
var node = JsonNode.Parse(/* your JSON string */);
var path = JsonPath.Parse("$.store.book[*].title");
var result = path.Evaluate(node);
Console.WriteLine(result.Matches?.Count ?? 0);C# JSONPath: quick start
- Write a JSONPath like
$.store.book[*]. - Use the evaluator above to validate results instantly.
- Copy the generated C# snippet and plug in your JSON + path.
JSONPath Syntax Cheatsheet
| Token | Meaning | Example |
|---|---|---|
| $ | Root object/array | $.store.book |
| @ | Current node (in filters) | $.book[?(@.price < 10)] |
| * | Wildcard | $.store.* |
| .. | Recursive descent | $..author |
| [n] | Array index | $.store.book[0] |
| [a,b] | Union | $.store.book[0,2] |
| [start:end] | Slice | $.store.book[0:2] |
| [?()] | Filter expression | $.store.book[?(@.category=='fiction')] |
C# JSONPath FAQ
▶How do I use JSONPath in C#?
Use the code generator below to copy a C# snippet, then replace the JSON and JSONPath expression with your own.
▶What is JSONPath?
JSONPath is a query language for JSON. It helps you select and extract values from JSON documents using path-like expressions.
▶How do I filter arrays in JSONPath?
Use filter expressions like $.items[?(@.price < 10)] to select array elements by conditions.
▶Why does my JSONPath return empty results?
Common reasons include invalid JSON input, a typo in keys, mismatched array/object structure, or using a JSONPath syntax not supported by your library.
▶Does this tool support recursive descent?
Yes. Use .. to search for keys at any depth, for example $..author.