JsonNode.Parse 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| Parse(String, Nullable<JsonNodeOptions>, JsonDocumentOptions) |
解析代表單一 JSON 值的文字。 |
| Parse(ReadOnlySpan<Byte>, Nullable<JsonNodeOptions>, JsonDocumentOptions) |
解析代表單一 JSON 值的文字。 |
| Parse(Utf8JsonReader, Nullable<JsonNodeOptions>) |
解析從所提供閱讀器中解析一個 JSON 值(包括物件或陣列)。 |
| Parse(Stream, Nullable<JsonNodeOptions>, JsonDocumentOptions) |
解析 Stream 一個 UTF-8 編碼的資料,代表單一 JSON 值 JsonNode。 《Stream》將被完整朗讀。 |
Parse(String, Nullable<JsonNodeOptions>, JsonDocumentOptions)
解析代表單一 JSON 值的文字。
public static System.Text.Json.Nodes.JsonNode? Parse(string json, System.Text.Json.Nodes.JsonNodeOptions? nodeOptions = default, System.Text.Json.JsonDocumentOptions documentOptions = default);
static member Parse : string * Nullable<System.Text.Json.Nodes.JsonNodeOptions> * System.Text.Json.JsonDocumentOptions -> System.Text.Json.Nodes.JsonNode
Public Shared Function Parse (json As String, Optional nodeOptions As Nullable(Of JsonNodeOptions) = Nothing, Optional documentOptions As JsonDocumentOptions = Nothing) As JsonNode
參數
- json
- String
JSON 文字來解析。
- nodeOptions
- Nullable<JsonNodeOptions>
解析後控制節點行為的選項。
- documentOptions
- JsonDocumentOptions
在解析過程中控制文件行為的選項。
傳回
JSON 值的 JsonNode 表示,或若輸入代表 null JSON 值則稱為 null。
例外狀況
json 是 null。
json 不代表有效的單一 JSON 值。
適用於
Parse(ReadOnlySpan<Byte>, Nullable<JsonNodeOptions>, JsonDocumentOptions)
解析代表單一 JSON 值的文字。
public static System.Text.Json.Nodes.JsonNode? Parse(ReadOnlySpan<byte> utf8Json, System.Text.Json.Nodes.JsonNodeOptions? nodeOptions = default, System.Text.Json.JsonDocumentOptions documentOptions = default);
static member Parse : ReadOnlySpan<byte> * Nullable<System.Text.Json.Nodes.JsonNodeOptions> * System.Text.Json.JsonDocumentOptions -> System.Text.Json.Nodes.JsonNode
Public Shared Function Parse (utf8Json As ReadOnlySpan(Of Byte), Optional nodeOptions As Nullable(Of JsonNodeOptions) = Nothing, Optional documentOptions As JsonDocumentOptions = Nothing) As JsonNode
參數
- utf8Json
- ReadOnlySpan<Byte>
JSON 文字來解析。
- nodeOptions
- Nullable<JsonNodeOptions>
解析後控制節點行為的選項。
- documentOptions
- JsonDocumentOptions
在解析過程中控制文件行為的選項。
傳回
JSON 值的 JsonNode 表示,或若輸入代表 null JSON 值則稱為 null。
例外狀況
utf8Json 不代表有效的單一 JSON 值。
適用於
Parse(Utf8JsonReader, Nullable<JsonNodeOptions>)
解析從所提供閱讀器中解析一個 JSON 值(包括物件或陣列)。
public static System.Text.Json.Nodes.JsonNode? Parse(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.Nodes.JsonNodeOptions? nodeOptions = default);
static member Parse : Utf8JsonReader * Nullable<System.Text.Json.Nodes.JsonNodeOptions> -> System.Text.Json.Nodes.JsonNode
Public Shared Function Parse (ByRef reader As Utf8JsonReader, Optional nodeOptions As Nullable(Of JsonNodeOptions) = Nothing) As JsonNode
參數
- reader
- Utf8JsonReader
讀者值得閱讀。
- nodeOptions
- Nullable<JsonNodeOptions>
控制行為的選項。
傳回
來自讀取器, JsonNode 或若輸入代表空 JSON 值則為 null。
例外狀況
reader 正在使用不支援的選項。
目前 reader 的代幣不會作為起始或代表一個價值。
讀取器無法讀取該值。
備註
若 TokenType 的reader屬性為或PropertyNameNone,讀取器將被推進一個呼叫,Read()以確定該值的起始。
完成此方法後, reader 定位於 JSON 值中的最終標記。 若拋出例外,讀取器會被重置回呼叫時的狀態。
此方法複製讀取器所操作的資料,因此呼叫者無需維持資料完整性,僅在此方法回傳後即可。
適用於
Parse(Stream, Nullable<JsonNodeOptions>, JsonDocumentOptions)
public static System.Text.Json.Nodes.JsonNode? Parse(System.IO.Stream utf8Json, System.Text.Json.Nodes.JsonNodeOptions? nodeOptions = default, System.Text.Json.JsonDocumentOptions documentOptions = default);
static member Parse : System.IO.Stream * Nullable<System.Text.Json.Nodes.JsonNodeOptions> * System.Text.Json.JsonDocumentOptions -> System.Text.Json.Nodes.JsonNode
Public Shared Function Parse (utf8Json As Stream, Optional nodeOptions As Nullable(Of JsonNodeOptions) = Nothing, Optional documentOptions As JsonDocumentOptions = Nothing) As JsonNode
參數
- utf8Json
- Stream
JSON 文字來解析。
- nodeOptions
- Nullable<JsonNodeOptions>
解析後控制節點行為的選項。
- documentOptions
- JsonDocumentOptions
在解析過程中控制文件行為的選項。
傳回
JSON 值的 JsonNode 表示,或若輸入代表 null JSON 值則稱為 null。
例外狀況
utf8Json 不代表有效的單一 JSON 值。