1/26
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
JsonNode
An abstract base class in System.Text.Json.Nodes that represents a node in the mutable JSON document object model. Domain: C# → .NET → System.Text.Json.Nodes → Mutable JSON DOM
Mutable JSON DOM
A JSON object model whose nodes can be created, modified, replaced, added, and removed after the JSON structure has been constructed or parsed.
JsonNode.Parse(json)
Parses JSON text and returns a JsonNode representing the root of the resulting mutable JSON structure.
JsonObject
A JsonNode-derived class that represents a mutable JSON object containing property-name and JSON-node pairs.
JsonArray
A JsonNode-derived class that represents a mutable ordered collection of JSON nodes.
JsonValue
A JsonNode-derived class that represents a primitive JSON value such as a string, number, or Boolean value.
new JsonObject()
Creates an empty mutable JSON object.
new JsonArray()
Creates an empty mutable JSON array.
node[propertyName]
Gets or sets a child node associated with a property name when working with a JSON object.
node[index]
Gets or sets the child node at a zero-based position when working with a JSON array.
jsonObject.Add(propertyName, value)
Adds a new named property and its value to a JsonObject.
jsonObject.Remove(propertyName)
Removes the property with the specified name from a JsonObject and reports whether removal occurred.
jsonObject.ContainsKey(propertyName)
Determines whether a JsonObject contains a property with the specified name.
jsonObject.TryGetPropertyValue(propertyName, out value)
Attempts to retrieve the JsonNode associated with a named property from a JsonObject.
jsonArray.Add(value)
Adds a value to the end of a JsonArray.
jsonArray.Insert(index, value)
Inserts a value into a JsonArray at the specified zero-based position.
jsonArray.RemoveAt(index)
Removes the JsonArray element at the specified zero-based position.
jsonArray.Count
Gets the number of elements currently contained in a JsonArray.
node.GetValue
Gets the value represented by a compatible JsonNode as the specified .NET type.
node.AsObject()
Returns the current JsonNode as a JsonObject when the node represents a JSON object.
node.AsArray()
Returns the current JsonNode as a JsonArray when the node represents a JSON array.
node.Parent
Gets the parent JsonNode containing the current node, or null when the node has no parent.
node.Root
Gets the topmost JsonNode in the tree containing the current node.
node.DeepClone()
Creates a recursive copy of the JsonNode and all of its descendant nodes.
node.ToJsonString()
Converts the JsonNode and its descendants into JSON text.
JsonNode Replacement
A child value in the mutable DOM can be replaced by assigning a new value or node through the appropriate property-name or array-index accessor.
JsonNode vs JsonDocument
JsonNode provides a mutable JSON DOM designed for creating and modifying JSON, whereas JsonDocument provides a read-only DOM optimized for examining JSON without modifying its structure.