Skip to content

JsonNodeConversionExtensions Class

Converts between the mutable JSON nodes a token is built from and the read-only elements a model carries.

C#
public static class JsonNodeConversionExtensions

Inheritance System.Object → JsonNodeConversionExtensions

Methods

JsonNodeConversionExtensions.ToJsonElement(this JsonNode) Method

Converts a JsonNode to a JsonElement.

C#
public static System.Text.Json.JsonElement ToJsonElement(this System.Text.Json.Nodes.JsonNode? jsonNode);

Parameters

jsonNode System.Text.Json.Nodes.JsonNode

The JsonNode to convert.

Returns

System.Text.Json.JsonElement
The converted JsonElement.

JsonNodeConversionExtensions.ToJsonNode(this JsonElement) Method

Converts a JsonElement to a JsonNode, allowing for more dynamic manipulation of the JSON structure.

C#
public static System.Text.Json.Nodes.JsonNode? ToJsonNode(this System.Text.Json.JsonElement jsonElement);

Parameters

jsonElement System.Text.Json.JsonElement

The JsonElement to convert.

Returns

System.Text.Json.Nodes.JsonNode
The converted JsonNode.

Remarks

This method is useful when you need to convert from a structured JsonElement to a more flexible JsonNode.