Skip to content

JsonElement.TryGetLineAndOffset Method

Definition

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

Overloads

Method Description
TryGetLineAndOffset(ref int, ref int) Tries to get the 1-based line number and character offset of this element in the original source document.
TryGetLineAndOffset(ref int, ref int, ref long) Tries to get the 1-based line number, character offset, and byte offset of this element in the original source document.

TryGetLineAndOffset(ref int, ref int)

Source: JsonElement.SourceLocation.cs

Tries to get the 1-based line number and character offset of this element in the original source document.

public bool TryGetLineAndOffset(ref int line, ref int charOffset)

Parameters

Name Type Description
line ref int When this method returns, contains the 1-based line number if successful.
charOffset ref int When this method returns, contains the 1-based character offset within the line if successful.

Returns

bool

true if the line and offset were successfully determined; otherwise, false.

Remarks

This method returns false when the backing document does not retain the original source bytes (for example, mutable builder documents or fixed-string documents).

Applies To

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

TryGetLineAndOffset(ref int, ref int, ref long)

Source: JsonElement.SourceLocation.cs

Tries to get the 1-based line number, character offset, and byte offset of this element in the original source document.

public bool TryGetLineAndOffset(ref int line, ref int charOffset, ref long lineByteOffset)

Parameters

Name Type Description
line ref int When this method returns, contains the 1-based line number if successful.
charOffset ref int When this method returns, contains the 1-based character offset within the line if successful.
lineByteOffset ref long When this method returns, contains the byte offset of the start of the line if successful.

Returns

bool

true if the line and offset were successfully determined; otherwise, false.

Remarks

This method returns false when the backing document does not retain the original source bytes (for example, mutable builder documents or fixed-string documents).

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