Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Text.​Json.​Nodes.​JsonArray
Assembly: System.Text.Json
Inheritance: object → JsonNode → JsonArray
Implemented Interfaces
- Collections.​Generic.​IList`1 (Inherits: ICollection<​Text.​Json.​Nodes.​JsonNode>IEnumerable<​Text.​Json.​Nodes.​JsonNode>IEnumerable)
Represents a mutable JSON array.
Properties
public
int
Count
Gets the number of elements contained in the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
public
JsonNode
Item
public
JsonNode
Item
public
JsonNodeOptions?
Options
Gets the options to control the behavior.
public
JsonNode
Parent
Gets the parent <see cref="T:System.Text.Json.Nodes.JsonNode" /> .
If there is no parent, <see langword="null" /> is returned.
A parent can either be a <see cref="T:System.Text.Json.Nodes.JsonObject" /> or a <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
public
JsonNode
Root
Gets the root <see cref="T:System.Text.Json.Nodes.JsonNode" /> .
Methods
public
void
Add​(JsonNode item)
Adds a <see cref="T:System.Text.Json.Nodes.JsonNode" /> to the end of the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
item
The <see cref="T:System.Text.Json.Nodes.JsonNode" /> to be added to the end of the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
public
void
Add​(T value)
Adds an object to the end of the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
value
The object to be added to the end of the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
public
void
Clear​()
Removes all elements from the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
public
bool
Contains​(JsonNode item)
Determines whether an element is in the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
Returns <see langword="true" /> if <paramref name="item" /> is found in the <see cref="T:System.Text.Json.Nodes.JsonArray" /> ; otherwise, <see langword="false" /> .
item
The object to locate in the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
public static
JsonArray
Create​(JsonElement element,
JsonNodeOptions? options = null)
Initializes a new instance of the <see cref="T:System.Text.Json.Nodes.JsonArray" /> class that contains items from the specified <see cref="T:System.Text.Json.JsonElement" /> .
Returns The new instance of the <see cref="T:System.Text.Json.Nodes.JsonArray" /> class that contains items from the specified <see cref="T:System.Text.Json.JsonElement" /> .
element
The <see cref="T:System.Text.Json.JsonElement" /> .
options
Options to control the behavior.
public
Collections.​Generic.​IEnumerator<​JsonNode>
GetEnumerator​()
Returns an enumerator that iterates through the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
Returns An <see cref="T:System.Collections.Generic.IEnumerator`1" /> for the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
public
Collections.​Generic.​IEnumerable<​T>
GetValues​()
Returns an enumerable that wraps calls to <see cref="M:System.Text.Json.Nodes.JsonNode.GetValue``1" /> .
Returns An enumerable iterating over values of the array.
public
int
IndexOf​(JsonNode item)
The object to locate in the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
Returns The index of item if found in the list; otherwise, -1.
item
The <see cref="T:System.Text.Json.Nodes.JsonNode" /> to locate in the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
public
void
Insert​(int index,
JsonNode item)
Inserts an element into the <see cref="T:System.Text.Json.Nodes.JsonArray" /> at the specified index.
index
The zero-based index at which <paramref name="item" /> should be inserted.
item
The <see cref="T:System.Text.Json.Nodes.JsonNode" /> to insert.
public
bool
Remove​(JsonNode item)
Removes the first occurrence of a specific <see cref="T:System.Text.Json.Nodes.JsonNode" /> from the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
Returns <see langword="true" /> if <paramref name="item" /> is successfully removed; otherwise, <see langword="false" /> .
item
The <see cref="T:System.Text.Json.Nodes.JsonNode" /> to remove from the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
public
void
RemoveAt​(int index)
Removes the element at the specified index of the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
index
The zero-based index of the element to remove.
public
int
RemoveAll​(Func<​JsonNode, bool> match)
Removes all the elements that match the conditions defined by the specified predicate.
Returns The number of elements removed from the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
match
The predicate that defines the conditions of the elements to remove.
public
void
RemoveRange​(int index,
int count)
Removes a range of elements from the <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
index
The zero-based starting index of the range of elements to remove.
count
The number of elements to remove.
public
void
WriteTo​(Utf8JsonWriter writer,
JsonSerializerOptions? options = null)
Writes the <see cref="T:System.Text.Json.Nodes.JsonNode" /> into the provided <see cref="T:System.Text.Json.Utf8JsonWriter" /> as JSON.
writer
The <see cref="T:System.Text.Json.Utf8JsonWriter" /> .
options
Options to control the serialization behavior.
public
JsonArray
AsArray​()
Inherited from JsonNode
Casts to the derived <see cref="T:System.Text.Json.Nodes.JsonArray" /> type.
Returns A <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
public
JsonObject
AsObject​()
Inherited from JsonNode
Casts to the derived <see cref="T:System.Text.Json.Nodes.JsonObject" /> type.
Returns A <see cref="T:System.Text.Json.Nodes.JsonObject" /> .
public
JsonValue
AsValue​()
Inherited from JsonNode
Casts to the derived <see cref="T:System.Text.Json.Nodes.JsonValue" /> type.
Returns A <see cref="T:System.Text.Json.Nodes.JsonValue" /> .
public
JsonNode
DeepClone​()
Inherited from JsonNode
Creates a new instance of the <see cref="T:System.Text.Json.Nodes.JsonNode" /> class. All child nodes are recursively cloned.
Returns A new cloned instance of the current node.
public
int
GetElementIndex​()
Inherited from JsonNode
Returns the index of the current node from the parent <see cref="T:System.Text.Json.Nodes.JsonArray" /> .
Returns The index of the current node.
Returns The JSON Path value.
public
string
GetPropertyName​()
Inherited from JsonNode
Returns the property name of the current node from the parent object.
Returns The property name of the current node.
public
JsonValueKind
GetValueKind​()
Inherited from JsonNode
Returns the <see cref="T:System.Text.Json.JsonValueKind" /> of the current instance.
Returns The json value kind of the current instance.
public
T
GetValue​()
Inherited from JsonNode
Gets the value for the current <see cref="T:System.Text.Json.Nodes.JsonValue" /> .
Returns A value converted from the <see cref="T:System.Text.Json.Nodes.JsonValue" /> instance.
public
void
ReplaceWith​(T value)
Inherited from JsonNode
Replaces this node with a new value.
value
The value that replaces this node.
public
string
ToJsonString​(JsonSerializerOptions? options = null)
Inherited from JsonNode
Converts the current instance to a string in JSON format.
Returns The JSON representation of the current instance.
options
Options to control the serialization behavior.
public
string
ToString​()
Inherited from JsonNode
Gets a string representation for the current value appropriate to the node type.
Returns A string representation for the current value appropriate to the node type.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object