Table of Contents

Class JsonPath

Namespace
Nerdbank.Json
Assembly
Nerdbank.Json.dll

An immutable, pre-parsed path that selects a single value within a JSON document for targeted deserialization.

public sealed class JsonPath
Inheritance
JsonPath
Inherited Members

Remarks

A path is a sequence of segments applied to the root JSON value. Each Member(string) segment selects an object property (or dictionary entry) by its serialized JSON name, and each Index(int) segment selects an array element by position. Because the names are the wire names, no naming policy is applied when a pre-parsed path is used; use the expression-based overloads of JsonSerializer when you want CLR member names translated automatically.

Instances are immutable and safe to cache and reuse across many deserialization calls, which avoids repeated path analysis on hot code paths.

Properties

Root

Gets the empty path, which selects the root value itself.

public static JsonPath Root { get; }

Property Value

JsonPath

Methods

Index(int)

Returns a path that appends selection of an array element by position.

public JsonPath Index(int index)

Parameters

index int

The zero-based element index.

Returns

JsonPath

A new path.

Member(string)

Returns a path that appends selection of an object property or dictionary entry by its serialized JSON name.

public JsonPath Member(string name)

Parameters

name string

The serialized JSON property name.

Returns

JsonPath

A new path.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.