JsonPathExtensions Class

Provides JSONPath evaluation helpers for JSON values.

public static class JsonPathExtensions

Methods

NameDescription
Evaluate(JsonDocument?, JsonPath)Evaluates a JSONPath expression against this JSON document.
Evaluate(JsonDocument?, JsonPath, JsonPathEvaluationMode)Evaluates a JSONPath expression against this JSON document.
Evaluate(JsonDocument?, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)Evaluates using cooperative cancellation and resource limits.
Evaluate(JsonElement, JsonPath)Evaluates a JSONPath expression against this JSON element.
Evaluate(JsonElement, JsonPath, JsonPathEvaluationMode)Evaluates a JSONPath expression against this JSON element.
Evaluate(JsonElement, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)Evaluates using cooperative cancellation and resource limits.
Evaluate(JsonNode?, JsonPath)Evaluates a JSONPath expression against this JSON value.
Evaluate(JsonNode?, JsonPath, JsonPathEvaluationMode)Evaluates a JSONPath expression against this JSON value.
Evaluate(JsonNode?, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)Evaluates using cooperative cancellation and resource limits.
EvaluateValue(JsonDocument?, JsonPath)Evaluates a JSONPath expression against this JSON document and returns the first matched value, or null when there is no match.
EvaluateValue(JsonDocument?, JsonPath, JsonPathEvaluationMode)Evaluates a JSONPath expression against this JSON document and returns the first matched value, or null when there is no match.
EvaluateValue(JsonDocument?, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)Returns the first value using cooperative cancellation and resource limits.
EvaluateValue(JsonElement, JsonPath)Evaluates a JSONPath expression against this JSON element and returns the first matched value, or null when there is no match.
EvaluateValue(JsonElement, JsonPath, JsonPathEvaluationMode)Evaluates a JSONPath expression against this JSON element and returns the first matched value, or null when there is no match.
EvaluateValue(JsonElement, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)Returns the first value using cooperative cancellation and resource limits.
EvaluateValue(JsonNode?, JsonPath)Evaluates a JSONPath expression against this JSON value and returns the first matched value, or null when there is no match.
EvaluateValue(JsonNode?, JsonPath, JsonPathEvaluationMode)Evaluates a JSONPath expression against this JSON value and returns the first matched value, or null when there is no match.
EvaluateValue(JsonNode?, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)Returns the first value using cooperative cancellation and resource limits.

Evaluate overloads

Evaluate(JsonDocument?, JsonPath)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON document.

public static JsonPathResult<JsonElement> Evaluate(this JsonDocument? root, JsonPath path)
Parameters
root JsonDocument?
The root JSON document to query. May be null.
path JsonPath
The JSONPath expression to evaluate.
Returns

JsonPathResult<JsonElement> A JsonPathResult<TValue> containing all matched nodes.

Exceptions
ArgumentNullException
path is null.

Evaluate(JsonDocument?, JsonPath, JsonPathEvaluationMode)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON document.

public static JsonPathResult<JsonElement> Evaluate(this JsonDocument? root, JsonPath path, JsonPathEvaluationMode mode)
Parameters
root JsonDocument?
The root JSON document to query. May be null.
path JsonPath
The JSONPath expression to evaluate.
mode JsonPathEvaluationMode
The evaluation mode.
Returns

JsonPathResult<JsonElement> A JsonPathResult<TValue> containing all matched nodes.

Exceptions
ArgumentNullException
path is null.
JsonPathEvaluationException
The path cannot be evaluated in JsonPathEvaluationMode.Strict mode.

Evaluate(JsonDocument?, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)

JsonPathExtensions.cs

Evaluates using cooperative cancellation and resource limits.

Evaluate(JsonElement, JsonPath)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON element.

public static JsonPathResult<JsonElement> Evaluate(this JsonElement root, JsonPath path)
Parameters
root JsonElement
The root JSON element to query.
path JsonPath
The JSONPath expression to evaluate.
Returns

JsonPathResult<JsonElement> A JsonPathResult<TValue> containing all matched nodes.

Exceptions
ArgumentNullException
path is null.

Evaluate(JsonElement, JsonPath, JsonPathEvaluationMode)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON element.

public static JsonPathResult<JsonElement> Evaluate(this JsonElement root, JsonPath path, JsonPathEvaluationMode mode)
Parameters
root JsonElement
The root JSON element to query.
path JsonPath
The JSONPath expression to evaluate.
mode JsonPathEvaluationMode
The evaluation mode.
Returns

JsonPathResult<JsonElement> A JsonPathResult<TValue> containing all matched nodes.

Exceptions
ArgumentNullException
path is null.
JsonPathEvaluationException
The path cannot be evaluated in JsonPathEvaluationMode.Strict mode.

Evaluate(JsonElement, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)

JsonPathExtensions.cs

Evaluates using cooperative cancellation and resource limits.

Evaluate(JsonNode?, JsonPath)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON value.

public static JsonPathResult Evaluate(this JsonNode? root, JsonPath path)
Parameters
root JsonNode?
The root JSON value to query. May be null.
path JsonPath
The JSONPath expression to evaluate.
Returns

JsonPathResult A JsonPathResult containing all matched nodes.

Exceptions
ArgumentNullException
path is null.

Evaluate(JsonNode?, JsonPath, JsonPathEvaluationMode)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON value.

public static JsonPathResult Evaluate(this JsonNode? root, JsonPath path, JsonPathEvaluationMode mode)
Parameters
root JsonNode?
The root JSON value to query. May be null.
path JsonPath
The JSONPath expression to evaluate.
mode JsonPathEvaluationMode
The evaluation mode.
Returns

JsonPathResult A JsonPathResult containing all matched nodes.

Exceptions
ArgumentNullException
path is null.
JsonPathEvaluationException
The path cannot be evaluated in JsonPathEvaluationMode.Strict mode.

Evaluate(JsonNode?, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)

JsonPathExtensions.cs

Evaluates using cooperative cancellation and resource limits.

public static JsonPathResult Evaluate(this JsonNode? root, JsonPath path, JsonPathEvaluationOptions options, JsonPathEvaluationMode mode = JsonPathEvaluationMode.Lax)

EvaluateValue overloads

EvaluateValue(JsonDocument?, JsonPath)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON document and returns the first matched value, or null when there is no match.

public static JsonElement? EvaluateValue(this JsonDocument? root, JsonPath path)
Parameters
root JsonDocument?
The root JSON document to query. May be null.
path JsonPath
The JSONPath expression to evaluate.
Returns

JsonElement? The first matched value, or null when there is no match.

Exceptions
ArgumentNullException
path is null.

EvaluateValue(JsonDocument?, JsonPath, JsonPathEvaluationMode)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON document and returns the first matched value, or null when there is no match.

public static JsonElement? EvaluateValue(this JsonDocument? root, JsonPath path, JsonPathEvaluationMode mode)
Parameters
root JsonDocument?
The root JSON document to query. May be null.
path JsonPath
The JSONPath expression to evaluate.
mode JsonPathEvaluationMode
The evaluation mode.
Returns

JsonElement? The first matched value, or null when there is no match.

Exceptions
ArgumentNullException
path is null.
JsonPathEvaluationException
The path cannot be evaluated in JsonPathEvaluationMode.Strict mode.

EvaluateValue(JsonDocument?, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)

JsonPathExtensions.cs

Returns the first value using cooperative cancellation and resource limits.

public static JsonElement? EvaluateValue(this JsonDocument? root, JsonPath path, JsonPathEvaluationOptions options, JsonPathEvaluationMode mode = JsonPathEvaluationMode.Lax)

EvaluateValue(JsonElement, JsonPath)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON element and returns the first matched value, or null when there is no match.

public static JsonElement? EvaluateValue(this JsonElement root, JsonPath path)
Parameters
root JsonElement
The root JSON element to query.
path JsonPath
The JSONPath expression to evaluate.
Returns

JsonElement? The first matched value, or null when there is no match.

Exceptions
ArgumentNullException
path is null.

EvaluateValue(JsonElement, JsonPath, JsonPathEvaluationMode)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON element and returns the first matched value, or null when there is no match.

public static JsonElement? EvaluateValue(this JsonElement root, JsonPath path, JsonPathEvaluationMode mode)
Parameters
root JsonElement
The root JSON element to query.
path JsonPath
The JSONPath expression to evaluate.
mode JsonPathEvaluationMode
The evaluation mode.
Returns

JsonElement? The first matched value, or null when there is no match.

Exceptions
ArgumentNullException
path is null.
JsonPathEvaluationException
The path cannot be evaluated in JsonPathEvaluationMode.Strict mode.

EvaluateValue(JsonElement, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)

JsonPathExtensions.cs

Returns the first value using cooperative cancellation and resource limits.

public static JsonElement? EvaluateValue(this JsonElement root, JsonPath path, JsonPathEvaluationOptions options, JsonPathEvaluationMode mode = JsonPathEvaluationMode.Lax)

EvaluateValue(JsonNode?, JsonPath)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON value and returns the first matched value, or null when there is no match.

public static JsonNode? EvaluateValue(this JsonNode? root, JsonPath path)
Parameters
root JsonNode?
The root JSON value to query. May be null.
path JsonPath
The JSONPath expression to evaluate.
Returns

JsonNode? The first matched value, or null when there is no match.

Exceptions
ArgumentNullException
path is null.

EvaluateValue(JsonNode?, JsonPath, JsonPathEvaluationMode)

JsonPathExtensions.cs

Evaluates a JSONPath expression against this JSON value and returns the first matched value, or null when there is no match.

public static JsonNode? EvaluateValue(this JsonNode? root, JsonPath path, JsonPathEvaluationMode mode)
Parameters
root JsonNode?
The root JSON value to query. May be null.
path JsonPath
The JSONPath expression to evaluate.
mode JsonPathEvaluationMode
The evaluation mode.
Returns

JsonNode? The first matched value, or null when there is no match.

Exceptions
ArgumentNullException
path is null.
JsonPathEvaluationException
The path cannot be evaluated in JsonPathEvaluationMode.Strict mode.

EvaluateValue(JsonNode?, JsonPath, JsonPathEvaluationOptions, JsonPathEvaluationMode)

JsonPathExtensions.cs

Returns the first value using cooperative cancellation and resource limits.

public static JsonNode? EvaluateValue(this JsonNode? root, JsonPath path, JsonPathEvaluationOptions options, JsonPathEvaluationMode mode = JsonPathEvaluationMode.Lax)