JsonNode.Parse Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Parse(String, Nullable<JsonNodeOptions>, JsonDocumentOptions) |
Parses text representing a single JSON value. |
Parse(ReadOnlySpan<Byte>, Nullable<JsonNodeOptions>, JsonDocumentOptions) |
Parses text representing a single JSON value. |
Parse(Utf8JsonReader, Nullable<JsonNodeOptions>) |
Parses one JSON value (including objects or arrays) from the provided reader. |
Parse(Stream, Nullable<JsonNodeOptions>, JsonDocumentOptions) |
Parses a Stream as UTF-8-encoded data representing a single JSON value into a JsonNode. The Stream will be read to completion. |
Parse(String, Nullable<JsonNodeOptions>, JsonDocumentOptions)
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
Parses text representing a single JSON value.
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
Parameters
- json
- String
JSON text to parse.
- nodeOptions
- Nullable<JsonNodeOptions>
Options to control the node behavior after parsing.
- documentOptions
- JsonDocumentOptions
Options to control the document behavior during parsing.
Returns
A JsonNode representation of the JSON value, or null if the input represents the null JSON value.
Exceptions
json
is null
.
json
does not represent a valid single JSON value.
Applies to
Parse(ReadOnlySpan<Byte>, Nullable<JsonNodeOptions>, JsonDocumentOptions)
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
Parses text representing a single JSON value.
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
Parameters
- utf8Json
- ReadOnlySpan<Byte>
JSON text to parse.
- nodeOptions
- Nullable<JsonNodeOptions>
Options to control the node behavior after parsing.
- documentOptions
- JsonDocumentOptions
Options to control the document behavior during parsing.
Returns
A JsonNode representation of the JSON value, or null if the input represents the null JSON value.
Exceptions
utf8Json
does not represent a valid single JSON value.
Applies to
Parse(Utf8JsonReader, Nullable<JsonNodeOptions>)
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
Parses one JSON value (including objects or arrays) from the provided reader.
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
Parameters
- reader
- Utf8JsonReader
The reader to read.
- nodeOptions
- Nullable<JsonNodeOptions>
Options to control the behavior.
Returns
The JsonNode from the reader, or null if the input represents the null JSON value.
Exceptions
reader
is using unsupported options.
The current reader
token does not start or represent a value.
A value could not be read from the reader.
Remarks
If the TokenType property of reader
is PropertyName or None, the reader will be advanced by one call to Read() to determine the start of the value.
Upon completion of this method, reader
is positioned at the final token in the JSON value. If an exception is thrown, the reader is reset to the state it was in when the method was called.
This method makes a copy of the data the reader acted on, so there is no caller requirement to maintain data integrity beyond the return of this method.
Applies to
Parse(Stream, Nullable<JsonNodeOptions>, JsonDocumentOptions)
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
- Source:
- JsonNode.Parse.cs
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
Parameters
- utf8Json
- Stream
JSON text to parse.
- nodeOptions
- Nullable<JsonNodeOptions>
Options to control the node behavior after parsing.
- documentOptions
- JsonDocumentOptions
Options to control the document behavior during parsing.
Returns
A JsonNode representation of the JSON value, or null if the input represents the null JSON value.
Exceptions
utf8Json
does not represent a valid single JSON value.