JsonDocument.TryParseValue(Utf8JsonReader, JsonDocument) 方法

定义

尝试通过提供的读取器分析一个 JSON 值(包括对象或数组)。

public:
 static bool TryParseValue(System::Text::Json::Utf8JsonReader % reader, [Runtime::InteropServices::Out] System::Text::Json::JsonDocument ^ % document);
public static bool TryParseValue (ref System.Text.Json.Utf8JsonReader reader, out System.Text.Json.JsonDocument? document);
public static bool TryParseValue (ref System.Text.Json.Utf8JsonReader reader, out System.Text.Json.JsonDocument document);
static member TryParseValue : Utf8JsonReader * JsonDocument -> bool
Public Shared Function TryParseValue (ByRef reader As Utf8JsonReader, ByRef document As JsonDocument) As Boolean

参数

reader
Utf8JsonReader

要用于读取的读取器。

document
JsonDocument

方法返回时,包含已分析的文档。

返回

Boolean

如果读取了值并将其分析为 JsonDocument,则为 true;如果读取器在分析时耗尽了数据,则为 false。 所有其他情况都会导致引发异常。

例外

reader 包含不受支持的选项。

  • 或 -

当前 reader 令牌不启动或表示值。

无法从读取器中读取值。

注解

TokenType reader如果属性为JsonTokenType.PropertyNameJsonTokenType.None,则读取器将先进行一次调用,以确定Utf8JsonReader.Read()值的开始。

完成此方法后, reader 将定位在 JSON 值的最终令牌上。 如果引发或 false 返回异常,则读取器将重置为调用该方法时处于的状态。

此方法创建读取器所操作的数据的副本,因此,在此方法返回之外,没有调用方要求维护数据完整性。

适用于