throwJsonReaderException.Create(reader,"Error reading JArray from JsonReader.");
}
}
reader.MoveToContent();
if(reader.TokenType!=JsonToken.StartArray)
{
throwJsonReaderException.Create(reader,"Error reading JArray from JsonReader. Current JsonReader item is not an array: {0}".FormatWith(CultureInfo.InvariantCulture,reader.TokenType));
}
JArraya=newJArray();
a.SetLineInfo(readerasIJsonLineInfo,settings);
a.ReadTokenFrom(reader,settings);
returna;
}
/// <summary>
/// Load a <see cref="JArray"/> from a string that contains JSON.
/// </summary>
/// <param name="json">A <see cref="String"/> that contains JSON.</param>
/// <returns>A <see cref="JArray"/> populated from the string that contains JSON.</returns>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParseArray" title="Parsing a JSON Array from Text" />
/// </example>
publicnewstaticJArrayParse(stringjson)
{
returnParse(json,null);
}
/// <summary>
/// Load a <see cref="JArray"/> from a string that contains JSON.
/// </summary>
/// <param name="json">A <see cref="String"/> that contains JSON.</param>
/// <param name="settings">The <see cref="JsonLoadSettings"/> used to load the JSON.
/// If this is <c>null</c>, default load settings will be used.</param>
/// <returns>A <see cref="JArray"/> populated from the string that contains JSON.</returns>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParseArray" title="Parsing a JSON Array from Text" />
/// <paramref name="index"/> is not a valid index in the <see cref="JArray"/>.
/// </exception>
publicvoidRemoveAt(intindex)
{
RemoveItemAt(index);
}
/// <summary>
/// Returns an enumerator that iterates through the collection.
/// </summary>
/// <returns>
/// A <see cref="IEnumerator{T}"/> of <see cref="JToken"/> that can be used to iterate through the collection.
/// </returns>
publicIEnumerator<JToken>GetEnumerator()
{
returnChildren().GetEnumerator();
}
#endregion
#region ICollection<JToken> Members
/// <summary>
/// Adds an item to the <see cref="JArray"/>.
/// </summary>
/// <param name="item">The object to add to the <see cref="JArray"/>.</param>
publicvoidAdd(JTokenitem)
{
Add((object)item);
}
/// <summary>
/// Removes all items from the <see cref="JArray"/>.
/// </summary>
publicvoidClear()
{
ClearItems();
}
/// <summary>
/// Determines whether the <see cref="JArray"/> contains a specific value.
/// </summary>
/// <param name="item">The object to locate in the <see cref="JArray"/>.</param>
/// <returns>
/// <c>true</c> if <paramref name="item"/> is found in the <see cref="JArray"/>; otherwise, <c>false</c>.
/// </returns>
publicboolContains(JTokenitem)
{
returnContainsItem(item);
}
/// <summary>
/// Copies the elements of the <see cref="JArray"/> to an array, starting at a particular array index.
/// </summary>
/// <param name="array">The array.</param>
/// <param name="arrayIndex">Index of the array.</param>
publicvoidCopyTo(JToken[]array,intarrayIndex)
{
CopyItemsTo(array,arrayIndex);
}
/// <summary>
/// Gets a value indicating whether the <see cref="JArray"/> is read-only.
/// </summary>
/// <returns><c>true</c> if the <see cref="JArray"/> is read-only; otherwise, <c>false</c>.</returns>
publicboolIsReadOnly=>false;
/// <summary>
/// Removes the first occurrence of a specific object from the <see cref="JArray"/>.
/// </summary>
/// <param name="item">The object to remove from the <see cref="JArray"/>.</param>
/// <returns>
/// <c>true</c> if <paramref name="item"/> was successfully removed from the <see cref="JArray"/>; otherwise, <c>false</c>. This method also returns <c>false</c> if <paramref name="item"/> is not found in the original <see cref="JArray"/>.