DynamicRest.JsonReader.ReadArray C# (CSharp) Method

ReadArray() private method

private ReadArray ( ) : JsonArray
return JsonArray
        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);
            }
        }