JsonDocument.Parse 方法

定義

多載

Parse(ReadOnlySequence<Byte>, JsonDocumentOptions)

將序列剖析為 UTF-8 編碼的文字,將單一 JSON 位元組值表示為 JsonDocument。Parses a sequence as UTF-8-encoded text representing a single JSON byte value into a JsonDocument.

Parse(Stream, JsonDocumentOptions)

Stream 剖析為 UTF-8 編碼的資料,將單一 JSON 值表示為 JsonDocument。Parses a Stream as UTF-8-encoded data representing a single JSON value into a JsonDocument. 資料流讀取完成。The stream is read to completion.

Parse(ReadOnlyMemory<Byte>, JsonDocumentOptions)

將記憶體剖析為 UTF-8 編碼的文字,將單一 JSON 位元組值表示為 JsonDocument。Parses memory as UTF-8-encoded text representing a single JSON byte value into a JsonDocument.

Parse(ReadOnlyMemory<Char>, JsonDocumentOptions)

將表示單一 JSON 字元值的文字剖析為 JsonDocument。Parses text representing a single JSON character value into a JsonDocument.

Parse(String, JsonDocumentOptions)

將表示單一 JSON 字串值的文字剖析為 JsonDocument。Parses text representing a single JSON string value into a JsonDocument.

Parse(ReadOnlySequence<Byte>, JsonDocumentOptions)

將序列剖析為 UTF-8 編碼的文字,將單一 JSON 位元組值表示為 JsonDocument。Parses a sequence as UTF-8-encoded text representing a single JSON byte value into a JsonDocument.

public static System.Text.Json.JsonDocument Parse (System.Buffers.ReadOnlySequence<byte> utf8Json, System.Text.Json.JsonDocumentOptions options = null);
static member Parse : System.Buffers.ReadOnlySequence<byte> * System.Text.Json.JsonDocumentOptions -> System.Text.Json.JsonDocument
Public Shared Function Parse (utf8Json As ReadOnlySequence(Of Byte), Optional options As JsonDocumentOptions = null) As JsonDocument

參數

utf8Json
ReadOnlySequence<Byte>

要剖析的 JSON 文字。The JSON text to parse.

options
JsonDocumentOptions

在剖析期間控制讀取器行為的選項。Options to control the reader behavior during parsing.

傳回

JSON 值的 JsonDocument 表示法。A JsonDocument representation of the JSON value.

例外狀況

utf8Json 不代表有效的單一 JSON 值。utf8Json does not represent a valid single JSON value.

readerOptions 包含不支援的選項。readerOptions contains unsupported options.

備註

ReadOnlySequence<T> 可用於 JsonDocument 物件的整個存留期,而且呼叫端必須確保其中的資料在物件存留期間不會變更。The ReadOnlySequence<T> may be used for the entire lifetime of the JsonDocument object, and the caller must ensure that the data therein does not change during the object lifetime. 因為輸入會被視為文字,所以必須不會出現 UTF-8 位元組順序標記(BOM)。Because the input is considered to be text, a UTF-8 Byte-Order-Mark (BOM) must not be present.

Parse(Stream, JsonDocumentOptions)

Stream 剖析為 UTF-8 編碼的資料,將單一 JSON 值表示為 JsonDocument。Parses a Stream as UTF-8-encoded data representing a single JSON value into a JsonDocument. 資料流讀取完成。The stream is read to completion.

public static System.Text.Json.JsonDocument Parse (System.IO.Stream utf8Json, System.Text.Json.JsonDocumentOptions options = null);
static member Parse : System.IO.Stream * System.Text.Json.JsonDocumentOptions -> System.Text.Json.JsonDocument
Public Shared Function Parse (utf8Json As Stream, Optional options As JsonDocumentOptions = null) As JsonDocument

參數

utf8Json
Stream

要剖析的 JSON 資料。The JSON data to parse.

options
JsonDocumentOptions

在剖析期間控制讀取器行為的選項。Options to control the reader behavior during parsing.

傳回

JSON 值的 JsonDocument 表示法。A JsonDocument representation of the JSON value.

例外狀況

utf8Json 不代表有效的單一 JSON 值。utf8Json does not represent a valid single JSON value.

readerOptions 包含不支援的選項。readerOptions contains unsupported options.

Parse(ReadOnlyMemory<Byte>, JsonDocumentOptions)

將記憶體剖析為 UTF-8 編碼的文字,將單一 JSON 位元組值表示為 JsonDocument。Parses memory as UTF-8-encoded text representing a single JSON byte value into a JsonDocument.

public static System.Text.Json.JsonDocument Parse (ReadOnlyMemory<byte> utf8Json, System.Text.Json.JsonDocumentOptions options = null);
static member Parse : ReadOnlyMemory<byte> * System.Text.Json.JsonDocumentOptions -> System.Text.Json.JsonDocument
Public Shared Function Parse (utf8Json As ReadOnlyMemory(Of Byte), Optional options As JsonDocumentOptions = null) As JsonDocument

參數

utf8Json
ReadOnlyMemory<Byte>

要剖析的 JSON 文字。The JSON text to parse.

options
JsonDocumentOptions

在剖析期間控制讀取器行為的選項。Options to control the reader behavior during parsing.

傳回

JSON 值的 JsonDocument 表示法。A JsonDocument representation of the JSON value.

例外狀況

utf8Json 不代表有效的單一 JSON 值。utf8Json does not represent a valid single JSON value.

readerOptions 包含不支援的選項。readerOptions contains unsupported options.

備註

ReadOnlyMemory<T> 值將用於 JsonDocument 物件的整個存留期,而且呼叫端必須確保其中的資料在物件存留期間不會變更。The ReadOnlyMemory<T> value will be used for the entire lifetime of the JsonDocument object, and the caller must ensure that the data therein does not change during the object lifetime.

因為輸入會被視為文字,所以必須不會出現 UTF-8 位元組順序標記(BOM)。Because the input is considered to be text, a UTF-8 Byte-Order-Mark (BOM) must not be present.

Parse(ReadOnlyMemory<Char>, JsonDocumentOptions)

將表示單一 JSON 字元值的文字剖析為 JsonDocument。Parses text representing a single JSON character value into a JsonDocument.

public static System.Text.Json.JsonDocument Parse (ReadOnlyMemory<char> json, System.Text.Json.JsonDocumentOptions options = null);
static member Parse : ReadOnlyMemory<char> * System.Text.Json.JsonDocumentOptions -> System.Text.Json.JsonDocument
Public Shared Function Parse (json As ReadOnlyMemory(Of Char), Optional options As JsonDocumentOptions = null) As JsonDocument

參數

json
ReadOnlyMemory<Char>

要剖析的 JSON 文字。The JSON text to parse.

options
JsonDocumentOptions

在剖析期間控制讀取器行為的選項。Options to control the reader behavior during parsing.

傳回

JSON 值的 JsonDocument 表示法。A JsonDocument representation of the JSON value.

例外狀況

json 不代表有效的單一 JSON 值。json does not represent a valid single JSON value.

readerOptions 包含不支援的選項。readerOptions contains unsupported options.

備註

ReadOnlyMemory<T> 值可用於 JsonDocument 物件的整個存留期,而且呼叫端必須確保其中的資料在物件存留期間不會變更。The ReadOnlyMemory<T> value may be used for the entire lifetime of the JsonDocument object, and the caller must ensure that the data therein does not change during the object lifetime.

Parse(String, JsonDocumentOptions)

將表示單一 JSON 字串值的文字剖析為 JsonDocument。Parses text representing a single JSON string value into a JsonDocument.

public static System.Text.Json.JsonDocument Parse (string json, System.Text.Json.JsonDocumentOptions options = null);
static member Parse : string * System.Text.Json.JsonDocumentOptions -> System.Text.Json.JsonDocument
Public Shared Function Parse (json As String, Optional options As JsonDocumentOptions = null) As JsonDocument

參數

json
String

要剖析的 JSON 文字。The JSON text to parse.

options
JsonDocumentOptions

在剖析期間控制讀取器行為的選項。Options to control the reader behavior during parsing.

傳回

JSON 值的 JsonDocument 表示法。A JsonDocument representation of the JSON value.

例外狀況

json 不代表有效的單一 JSON 值。json does not represent a valid single JSON value.

readerOptions 包含不支援的選項。readerOptions contains unsupported options.

適用於