JsonObject.Insert(Int32, String, JsonNode) Method

Definition

Inserts a property into the object at the specified index.

C#
public void Insert(int index, string propertyName, System.Text.Json.Nodes.JsonNode? value);

Parameters

index
Int32

The zero-based index at which the property should be inserted.

propertyName
String

The property name to insert.

value
JsonNode

The JSON value to insert.

Exceptions

propertyName is null.

An element with the same key already exists in the JsonObject.

index is less than 0 or greater than Count.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)