Skip to content

JsonElement.TryGetJsonPointer Method

Definition

Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll

Overloads

Method Description
TryGetJsonPointer(Span<byte>, int) Tries to write the JSON Pointer (RFC 6901) of this element, relative to the root of its backing document, as UTF-8 bytes.
TryGetJsonPointer(Span<char>, int) Tries to write the JSON Pointer (RFC 6901) of this element, relative to the root of its backing document, as UTF-16 characters.

TryGetJsonPointer(Span<byte>, int)

Source: JsonElement.JsonPointer.cs

Tries to write the JSON Pointer (RFC 6901) of this element, relative to the root of its backing document, as UTF-8 bytes.

public bool TryGetJsonPointer(Span<byte> utf8Destination, out int bytesWritten)

Parameters

Name Type Description
utf8Destination Span<byte> The destination for the UTF-8 pointer text.
bytesWritten int When this method returns true, the number of bytes written; otherwise 0.

Returns

bool

true if the pointer was written; false if the destination was too small, or this is a default JsonElement.

Exceptions

Exception Description
ObjectDisposedException The parent JsonDocument has been disposed.

Remarks

The root element produces the empty pointer. Property names are unescaped and then pointer-escaped (~ as ~0, / as ~1) per RFC 6901. This operation performs no heap allocation. The pointer is relative to the root of the document that backs this element. In a JsonWorkspace, an element obtained from another document referenced by a builder reports its location within that referenced document.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

TryGetJsonPointer(Span<char>, int)

Source: JsonElement.JsonPointer.cs

Tries to write the JSON Pointer (RFC 6901) of this element, relative to the root of its backing document, as UTF-16 characters.

public bool TryGetJsonPointer(Span<char> destination, out int charsWritten)

Parameters

Name Type Description
destination Span<char> The destination for the pointer text.
charsWritten int When this method returns true, the number of characters written; otherwise 0.

Returns

bool

true if the pointer was written; false if the destination was too small, or this is a default JsonElement.

Exceptions

Exception Description
ObjectDisposedException The parent JsonDocument has been disposed.

Remarks

The root element produces the empty pointer. Property names are unescaped and then pointer-escaped (~ as ~0, / as ~1) per RFC 6901. This operation performs no heap allocation. The pointer is relative to the root of the document that backs this element. In a JsonWorkspace, an element obtained from another document referenced by a builder reports its location within that referenced document.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests.

Open an issue