<PackageReference Include="System.ClientModel" Version="1.8.0" />

System.ClientModel.Primitives.JsonPathExtensions

static class JsonPathExtensions
public static bool Advance(this ref Utf8JsonReader jsonReader, ReadOnlySpan<byte> jsonPath, ref Utf8JsonReader last)

Advances the Utf8JsonReader to the position specified by the provided JSON path.

public static bool Advance(this ref Utf8JsonReader jsonReader, ReadOnlySpan<byte> jsonPath)

public static bool Advance(this ref Utf8JsonReader jsonReader, ref JsonPathReader pathReader)

public static bool Advance(this ref Utf8JsonReader jsonReader, ref JsonPathReader pathReader, ref Utf8JsonReader last)

Advances the Utf8JsonReader to the position specified by the provided JsonPathReader.

public static byte[] Append(this ReadOnlyMemory<byte> json, ReadOnlySpan<byte> arrayPath, ReadOnlyMemory<byte> jsonToInsert)

Appends the specified JSON value to the end of the array at the specified array path in the original JSON byte array.

public static int ConvertToJsonPointer(this byte[] jsonPath, Span<byte> buffer, bool isArrayAppend = false)

Converts JSON path RFC 9535 to JSON Pointer RFC 6901 format.

public static int GetArrayLength(this ref Utf8JsonReader jsonReader, ReadOnlySpan<byte> arrayPath)

Gets the length of the array at the specified JSON path from the original JSON byte array.

public static ReadOnlySpan<byte> GetFirstNonIndexParent(this byte[] jsonPath)

Gets the first parent path that is not an array index from the specified JSON path. For example for the JSON path "$.store.book[0].title", this method will return "$.store.book[0].title". If the JSON path is "$.store.book[0][1]", this method will return "$.store.book".

public static ReadOnlySpan<byte> GetFirstProperty(this ReadOnlySpan<byte> jsonPath)

public static ReadOnlySpan<byte> GetIndexSpan(this byte[] jsonPath)

public static ReadOnlySpan<byte> GetIndexSpan(this ReadOnlySpan<byte> jsonPath)

Gets the index span of the current JSON path if it is an array index. For example for the JSON path "$.store.book[0]", this method will return "0".

public static ReadOnlyMemory<byte> GetJson(this ReadOnlyMemory<byte> json, ReadOnlySpan<byte> jsonPath)

Gets the JSON value at the specified JSON path from the original JSON byte array.

public static ReadOnlySpan<byte> GetParent(this byte[] jsonPath)

public static ReadOnlySpan<byte> GetParent(this ReadOnlySpan<byte> jsonPath)

Gets the parent JSON path of the specified JSON path. For example for the JSON path "$.store.book[0].title", this method will return "$.store.book[0]".

public static ReadOnlySpan<byte> GetPropertyName(this byte[] jsonPath)

public static ReadOnlySpan<byte> GetPropertyName(this ReadOnlySpan<byte> jsonPath)

Gets the property name of the current JSON path. For example for the JSON path "$.store.book[0].title", this method will return "title".

public static ReadOnlySpan<byte> GetPropertyNameFromSlice(this ReadOnlySpan<byte> slice)

Extracts the first property name from a JSON path slice, ignoring any leading root or array index syntax. Does not assume we have a full JSON path, just a slice that may start with a property name. For example, for the JSON path slice ".store.book[0].title", this method will return "store".

public static byte[] InsertAt(this ReadOnlyMemory<byte> json, ReadOnlySpan<byte> arrayPath, ReadOnlyMemory<byte> jsonToInsert)

Inserts the specified JSON value at the specified array path in the original JSON byte array. If the array at the specified path does not exist, it will be created and filled with null values up to the specified index.

public static bool IsArrayIndex(this byte[] jsonPath)

public static bool IsArrayIndex(this ReadOnlySpan<byte> jsonPath)

public static bool IsRoot(this byte[] jsonPath)

public static bool IsRoot(this Span<byte> jsonPath)

public static bool IsRoot(this ReadOnlySpan<byte> jsonPath)

Gets whether or not the specified JSON path represents the root of the JSON document.

public static byte[] Remove(this ReadOnlyMemory<byte> json, ReadOnlySpan<byte> jsonPath)

Removes the JSON value at the specified JSON path from the JSON byte array.

public static byte[] Set(this ReadOnlyMemory<byte> json, ReadOnlySpan<byte> jsonPath, ReadOnlyMemory<byte> jsonReplacement)

Sets the value of the JSON at the specified JSON path to the provided replacement JSON value. If the jsonPath does not exist in the original JSON, it will be added with the jsonReplacement value.

public static byte[] SetCurrentValue(this Utf8JsonReader jsonReader, bool wasFound, ReadOnlySpan<byte> propertyName, ReadOnlyMemory<byte> json, ReadOnlyMemory<byte> jsonReplacement)

Sets the value of the JSON at the current position of the jsonReader to the provided replacement JSON value.

public static bool TryGetJson(this ReadOnlyMemory<byte> json, ReadOnlySpan<byte> jsonPath, out ReadOnlyMemory target)

Tries to get the JSON value at the specified JSON path from the original JSON byte array.