Table of Contents

Class JContainer

Namespace
Newtonsoft.Json.Linq
Assembly
Newtonsoft.Json.dll

Represents a token that can contain other tokens.

public abstract class JContainer : JToken, IJEnumerable<JToken>, IJsonLineInfo, ICloneable, IList<JToken>, ICollection<JToken>, IEnumerable<JToken>, ITypedList, IBindingList, IList, ICollection, IEnumerable
Inheritance
JContainer
Implements
Derived
Inherited Members
Extension Methods

Properties

ChildrenTokens

Gets the container's children tokens.

protected abstract IList<JToken> ChildrenTokens { get; }

Property Value

IList<JToken>

The container's children tokens.

Count

Gets the count of child JSON tokens.

public int Count { get; }

Property Value

int

The count of child JSON tokens

First

Get the first child token of this token.

public override JToken First { get; }

Property Value

JToken

A JToken containing the first child token of the JToken.

HasValues

Gets a value indicating whether this token has childen tokens.

public override bool HasValues { get; }

Property Value

bool

true if this token has child values; otherwise, false.

Last

Get the last child token of this token.

public override JToken Last { get; }

Property Value

JToken

A JToken containing the last child token of the JToken.

Methods

Add(object)

Adds the specified content as children of this JToken.

public virtual void Add(object content)

Parameters

content object

The content to be added.

AddFirst(object)

Adds the specified content as the first children of this JToken.

public void AddFirst(object content)

Parameters

content object

The content to be added.

Children()

Returns a collection of the child tokens of this token, in document order.

public override JEnumerable<JToken> Children()

Returns

JEnumerable<JToken>

An IEnumerable<T> of JToken containing the child tokens of this JToken, in document order.

CreateWriter()

Creates an JsonWriter that can be used to add tokens to the JToken.

public JsonWriter CreateWriter()

Returns

JsonWriter

An JsonWriter that is ready to have content written to it.

Descendants()

Returns a collection of the descendant tokens for this token in document order.

public IEnumerable<JToken> Descendants()

Returns

IEnumerable<JToken>

An IEnumerable<T> containing the descendant tokens of the JToken.

OnAddingNew(AddingNewEventArgs)

Raises the AddingNew event.

protected virtual void OnAddingNew(AddingNewEventArgs e)

Parameters

e AddingNewEventArgs

The AddingNewEventArgs instance containing the event data.

OnListChanged(ListChangedEventArgs)

Raises the ListChanged event.

protected virtual void OnListChanged(ListChangedEventArgs e)

Parameters

e ListChangedEventArgs

The ListChangedEventArgs instance containing the event data.

RemoveAll()

Removes the child nodes from this token.

public void RemoveAll()

ReplaceAll(object)

Replaces the children nodes of this token with the specified content.

public void ReplaceAll(object content)

Parameters

content object

The content.

Values<T>()

Returns a collection of the child values of this token, in document order.

public override IEnumerable<T> Values<T>()

Returns

IEnumerable<T>

A IEnumerable<T> containing the child values of this JToken, in document order.

Type Parameters

T

The type to convert the values to.

Events

AddingNew

Occurs before an item is added to the collection.

public event AddingNewEventHandler AddingNew

Event Type

AddingNewEventHandler

ListChanged

Occurs when the list changes or an item in the list changes.

public event ListChangedEventHandler ListChanged

Event Type

ListChangedEventHandler