JsonPathNavigator<TValue> Class

Provides JSONPath navigation services for a custom object model.

public abstract class JsonPathNavigator<TValue>

Type parameters

TValue
The node type used by the custom object model.

Constructors

NameDescription
JsonPathNavigator()

JsonPathNavigator()

protected JsonPathNavigator()

No documentation is available.

Properties

NameDescription
HasConstantTimeElementAccessGets whether JsonPathNavigator<TValue>.TryGetElement takes constant time. When it does not, the evaluator copies an array with JsonPathNavigator<TValue>.CopyElements before walking it, so that visiting every element stays linear.
HasConstantTimePropertyLookupGets whether JsonPathNavigator<TValue>.TryGetPropertyValue takes constant time.
IsPureGets whether navigation is side-effect-free and values remain stable throughout an evaluation.

HasConstantTimeElementAccess

JsonPathNavigator`1.cs

Gets whether JsonPathNavigator<TValue>.TryGetElement takes constant time. When it does not, the evaluator copies an array with JsonPathNavigator<TValue>.CopyElements before walking it, so that visiting every element stays linear.

public virtual bool HasConstantTimeElementAccess { get; }

Property value

bool

HasConstantTimePropertyLookup

JsonPathNavigator`1.cs

Gets whether JsonPathNavigator<TValue>.TryGetPropertyValue takes constant time.

public virtual bool HasConstantTimePropertyLookup { get; }

Property value

bool

Remarks

When this is false, the evaluator enumerates the right object once to build an ordinal lookup table when comparing objects for equality. If a name occurs more than once, the last value is used and earlier values are ignored, matching the semantics of JsonPathNavigator<TValue>.TryGetPropertyValue.

Gets whether navigation is side-effect-free and values remain stable throughout an evaluation.

public virtual bool IsPure { get; }

Property value

bool

Remarks

Override with true to permit per-evaluation reuse of root-invariant built-in function results. The default is false.

Methods

NameDescription
CopyElements(TValue?, TValue?[])Copies the elements of an array, in index order, to the start of destination.
GetArrayLength(TValue?)Gets an array length.
GetKind(TValue?)Gets the JSON node kind represented by value.
GetProperties(TValue?)Gets object properties in enumeration order.
TryGetBoolean(TValue?, bool)Gets a boolean scalar value.
TryGetElement(TValue?, int, TValue?)Gets an array element by zero-based index.
TryGetNumber(TValue?, double)Gets a number scalar value.
TryGetPropertyValue(TValue?, string, TValue?)Gets an object property value.
TryGetString(TValue?, string?)Gets a string scalar value.

CopyElements(TValue?, TValue?[])

JsonPathNavigator`1.cs

Copies the elements of an array, in index order, to the start of destination.

public virtual void CopyElements(TValue? value, TValue?[] destination)

Parameters

value TValue?
The array value.
destination TValue?[]
A buffer holding at least JsonPathNavigator<TValue>.GetArrayLength items.

Remarks

Implementations must write the first JsonPathNavigator<TValue>.GetArrayLength items in index order. If an element cannot be retrieved, write default at its index.

GetArrayLength(TValue?)

Gets an array length.

public abstract int GetArrayLength(TValue? value)

Parameters

value TValue?
The array value.

Returns

int The array length.

GetKind(TValue?)

Gets the JSON node kind represented by value.

public abstract JsonPathNodeKind GetKind(TValue? value)

Parameters

value TValue?
The value to inspect. Navigators may use null or a model-specific value to represent JSON null.

Returns

JsonPathNodeKind The JSON node kind represented by value.

GetProperties(TValue?)

Gets object properties in enumeration order.

public abstract IEnumerable<JsonPathProperty<TValue>> GetProperties(TValue? value)

Parameters

value TValue?
The object value.

Returns

IEnumerable<JsonPathProperty<TValue>> The object properties in enumeration order.

TryGetBoolean(TValue?, bool)

Gets a boolean scalar value.

public abstract bool TryGetBoolean(TValue? value, out bool result)

Parameters

value TValue?
The scalar value.
result bool
When this method returns, contains the boolean value.

Returns

bool true when value represents a boolean; otherwise, false.

TryGetElement(TValue?, int, TValue?)

Gets an array element by zero-based index.

public abstract bool TryGetElement(TValue? value, int index, out TValue? result)

Parameters

value TValue?
The array value.
index int
The zero-based array index.
result TValue?
When this method returns, contains the element value if it exists.

Returns

bool true when the element exists; otherwise, false.

TryGetNumber(TValue?, double)

Gets a number scalar value.

public abstract bool TryGetNumber(TValue? value, out double result)

Parameters

value TValue?
The scalar value.
result double
When this method returns, contains the number value.

Returns

bool true when value represents a number; otherwise, false.

TryGetPropertyValue(TValue?, string, TValue?)

Gets an object property value.

public abstract bool TryGetPropertyValue(TValue? value, string name, out TValue? result)

Parameters

value TValue?
The object value.
name string
The property name.
result TValue?
When this method returns, contains the property value if it exists.

Returns

bool true when the property exists; otherwise, false.

TryGetString(TValue?, string?)

Gets a string scalar value.

public abstract bool TryGetString(TValue? value, out string? result)

Parameters

value TValue?
The scalar value.
result string?
When this method returns, contains the string value.

Returns

bool true when value represents a string; otherwise, false.