JsonObject.Add Method

Definition

Overloads

Add(KeyValuePair<String,JsonNode>)

Adds the specified property to the JsonObject.

Add(String, JsonNode)

Adds an element with the provided property name and value to the JsonObject.

Add(KeyValuePair<String,JsonNode>)

Source:
JsonObject.IDictionary.cs
Source:
JsonObject.IDictionary.cs
Source:
JsonObject.IDictionary.cs
Source:
JsonObject.IDictionary.cs
Source:
JsonObject.IDictionary.cs
Source:
JsonObject.IDictionary.cs

Adds the specified property to the JsonObject.

C#
public void Add(System.Collections.Generic.KeyValuePair<string,System.Text.Json.Nodes.JsonNode?> property);

Parameters

property
KeyValuePair<String,JsonNode>

The KeyValuePair structure representing the property name and value to add to the JsonObject.

Implements

Exceptions

An element with the same property name already exists in the JsonObject.

The property name of property is null.

Applies to

.NET 10 and other versions
Product Versions
.NET 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Add(String, JsonNode)

Source:
JsonObject.IDictionary.cs
Source:
JsonObject.IDictionary.cs
Source:
JsonObject.IDictionary.cs
Source:
JsonObject.IDictionary.cs
Source:
JsonObject.IDictionary.cs
Source:
JsonObject.IDictionary.cs

Adds an element with the provided property name and value to the JsonObject.

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

Parameters

propertyName
String

The property name of the element to add.

value
JsonNode

The value of the element to add.

Implements

Exceptions

propertyNameis null.

An element with the same property name already exists in the JsonObject.

Applies to

.NET 10 and other versions
Product Versions
.NET 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)