/// <inheritdoc /> public JsonItem ParseNext() { List <JsonItem> items = new List <JsonItem>(); JsonItem item; this.state = JsonArrayParseState.Start; while (this.state != JsonArrayParseState.End) { switch (this.state) { case JsonArrayParseState.Start: if (this.Consume('[')) { this.state = JsonArrayParseState.Value; new JsonWhiteSpaceParser(JsonParseType.Array, this.Buffer).ParseNext(); } else { return(this.MakeError('[')); } break; case JsonArrayParseState.Value: if (this.Consume(']')) { this.state = JsonArrayParseState.End; } else { item = new JsonValueParser(this.Buffer).ParseNext(); if (item.IsError) { return(item); } items.Add(item); new JsonWhiteSpaceParser(JsonParseType.Array, this.Buffer).ParseNext(); this.state = JsonArrayParseState.Seperator; } break; case JsonArrayParseState.Seperator: if (this.Consume(',')) { new JsonWhiteSpaceParser(JsonParseType.Array, this.Buffer).ParseNext(); this.state = JsonArrayParseState.Value; } else if (this.Consume(']')) { this.state = JsonArrayParseState.End; } else { return(this.MakeError(',', ']')); } break; } } return(new JsonArray(items)); }
/// <inheritdoc /> public JsonItem ParseNext() { List<JsonItem> items = new List<JsonItem>(); JsonItem item; this.state = JsonArrayParseState.Start; while (this.state != JsonArrayParseState.End) { switch (this.state) { case JsonArrayParseState.Start: if (this.Consume('[')) { this.state = JsonArrayParseState.Value; new JsonWhiteSpaceParser(JsonParseType.Array, this.Buffer).ParseNext(); } else { return this.MakeError('['); } break; case JsonArrayParseState.Value: if (this.Consume(']')) { this.state = JsonArrayParseState.End; } else { item = new JsonValueParser(this.Buffer).ParseNext(); if (item.IsError) { return item; } items.Add(item); new JsonWhiteSpaceParser(JsonParseType.Array, this.Buffer).ParseNext(); this.state = JsonArrayParseState.Seperator; } break; case JsonArrayParseState.Seperator: if (this.Consume(',')) { new JsonWhiteSpaceParser(JsonParseType.Array, this.Buffer).ParseNext(); this.state = JsonArrayParseState.Value; } else if (this.Consume(']')) { this.state = JsonArrayParseState.End; } else { return this.MakeError(',', ']'); } break; } } return new JsonArray(items); }