private JsonArray ReadArray()
{
JsonArray array = new JsonArray();
ICollection<object> arrayItems = (ICollection<object>)array;
// Consume the '['
_reader.Read();
while (true) {
char ch = PeekNextSignificantCharacter();
if (ch == '\0') {
throw new FormatException("Unterminated array literal.");
}
if (ch == ']') {
_reader.Read();
return array;
}
if (arrayItems.Count != 0) {
if (ch != ',') {
throw new FormatException("Invalid array literal.");
}
else {
_reader.Read();
}
}
object item = ReadValue();
arrayItems.Add(item);
}
}