ParsedJsonDocument<T>.Parse Method
Definition
Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll
Overloads
| Method | Description |
|---|---|
| Parse(ReadOnlyMemory<byte>, JsonDocumentOptions) | Parse memory as UTF-8 encoded text representing a single JSON value into a ParsedJsonDocument. |
| Parse(ReadOnlyMemory<byte>, byte[], JsonDocumentOptions) | Parse UTF-8 encoded text representing a single JSON value into a ParsedJsonDocument, taking ownership of a rented ArrayPool by... |
| Parse(ReadOnlySequence<byte>, JsonDocumentOptions) | Parse a sequence as UTF-8 encoded text representing a single JSON value into a ParsedJsonDocument. |
| Parse(Stream, JsonDocumentOptions) | Parse a Stream as UTF-8 encoded data representing a single JSON value into a ParsedJsonDocument. The Stream will be read to completion. |
| Parse(ReadOnlyMemory<char>, JsonDocumentOptions) | Parses text representing a single JSON value into a ParsedJsonDocument. |
| Parse(string, JsonDocumentOptions) | Parses text representing a single JSON value into a ParsedJsonDocument. |
Parse(ReadOnlyMemory<byte>, JsonDocumentOptions)
Source: ParsedJsonDocument.Parse.cs
Parse memory as UTF-8 encoded text representing a single JSON value into a ParsedJsonDocument.
public static ParsedJsonDocument<T> Parse(ReadOnlyMemory<byte> utf8Json, JsonDocumentOptions options)
Parameters
| Name | Type | Description |
|---|---|---|
utf8Json |
ReadOnlyMemory<byte> |
JSON text to parse. |
options |
JsonDocumentOptions |
Options to control the reader behavior during parsing. (optional) |
Returns
A ParsedJsonDocument representation of the JSON value.
Exceptions
| Exception | Description |
|---|---|
JsonException |
utf8Json does not represent a valid single JSON value. |
ArgumentException |
options contains unsupported options. |
Remarks
The ReadOnlyMemory value will be used for the entire lifetime of the ParsedJsonDocument object, and the caller must ensure that the data therein does not change during the object lifetime. Because the input is considered to be text, a UTF-8 Byte-Order-Mark (BOM) must not be present.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
Parse(ReadOnlyMemory<byte>, byte[], JsonDocumentOptions)
Source: ParsedJsonDocument.Parse.cs
Parse UTF-8 encoded text representing a single JSON value into a ParsedJsonDocument, taking ownership of a rented ArrayPool byte array that backs the memory.
public static ParsedJsonDocument<T> Parse(ReadOnlyMemory<byte> utf8Json, byte[] rentedArrayPoolBytes, JsonDocumentOptions options)
Parameters
| Name | Type | Description |
|---|---|---|
utf8Json |
ReadOnlyMemory<byte> |
JSON text to parse. Must be a slice of rentedArrayPoolBytes. |
rentedArrayPoolBytes |
byte[] |
A byte array rented from Shared that backs utf8Json. Ownership is transferred to the returned document. |
options |
JsonDocumentOptions |
Options to control the reader behavior during parsing. (optional) |
Returns
A ParsedJsonDocument representation of the JSON value.
Exceptions
| Exception | Description |
|---|---|
JsonException |
utf8Json does not represent a valid single JSON value. |
ArgumentException |
options contains unsupported options. |
Remarks
The utf8Json memory must be a slice of rentedArrayPoolBytes. The document takes ownership of the rented array and will return it to Shared when the document is disposed. The caller must not use rentedArrayPoolBytes after calling this method.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
Parse(ReadOnlySequence<byte>, JsonDocumentOptions)
Source: ParsedJsonDocument.Parse.cs
Parse a sequence as UTF-8 encoded text representing a single JSON value into a ParsedJsonDocument.
public static ParsedJsonDocument<T> Parse(ReadOnlySequence<byte> utf8Json, JsonDocumentOptions options)
Parameters
| Name | Type | Description |
|---|---|---|
utf8Json |
ReadOnlySequence<byte> |
JSON text to parse. |
options |
JsonDocumentOptions |
Options to control the reader behavior during parsing. (optional) |
Returns
A ParsedJsonDocument representation of the JSON value.
Exceptions
| Exception | Description |
|---|---|
JsonException |
utf8Json does not represent a valid single JSON value. |
ArgumentException |
options contains unsupported options. |
Remarks
The ReadOnlySequence may be used for the entire lifetime of the ParsedJsonDocument object, and the caller must ensure that the data therein does not change during the object lifetime. Because the input is considered to be text, a UTF-8 Byte-Order-Mark (BOM) must not be present.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
Parse(Stream, JsonDocumentOptions)
Source: ParsedJsonDocument.Parse.cs
Parse a Stream as UTF-8 encoded data representing a single JSON value into a ParsedJsonDocument. The Stream will be read to completion.
public static ParsedJsonDocument<T> Parse(Stream utf8Json, JsonDocumentOptions options)
Parameters
| Name | Type | Description |
|---|---|---|
utf8Json |
Stream |
JSON data to parse. |
options |
JsonDocumentOptions |
Options to control the reader behavior during parsing. (optional) |
Returns
A ParsedJsonDocument representation of the JSON value.
Exceptions
| Exception | Description |
|---|---|
JsonException |
utf8Json does not represent a valid single JSON value. |
ArgumentException |
options contains unsupported options. |
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
Parse(ReadOnlyMemory<char>, JsonDocumentOptions)
Source: ParsedJsonDocument.Parse.cs
Parses text representing a single JSON value into a ParsedJsonDocument.
public static ParsedJsonDocument<T> Parse(ReadOnlyMemory<char> json, JsonDocumentOptions options)
Parameters
| Name | Type | Description |
|---|---|---|
json |
ReadOnlyMemory<char> |
JSON text to parse. |
options |
JsonDocumentOptions |
Options to control the reader behavior during parsing. (optional) |
Returns
A ParsedJsonDocument representation of the JSON value.
Exceptions
| Exception | Description |
|---|---|
JsonException |
json does not represent a valid single JSON value. |
ArgumentException |
options contains unsupported options. |
Remarks
The ReadOnlyMemory value may be used for the entire lifetime of the ParsedJsonDocument object, and the caller must ensure that the data therein does not change during the object lifetime.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
Parse(string, JsonDocumentOptions)
Source: ParsedJsonDocument.Parse.cs
Parses text representing a single JSON value into a ParsedJsonDocument.
public static ParsedJsonDocument<T> Parse(string json, JsonDocumentOptions options)
Parameters
| Name | Type | Description |
|---|---|---|
json |
string |
JSON text to parse. |
options |
JsonDocumentOptions |
Options to control the reader behavior during parsing. (optional) |
Returns
A ParsedJsonDocument representation of the JSON value.
Exceptions
| Exception | Description |
|---|---|
JsonException |
json does not represent a valid single JSON value. |
ArgumentException |
options contains unsupported options. |
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