public override void PopulateElement(JStream stream) { if (stream.Char == '[') { stream.Next(); } else { throw new Exception(string.Format("Cannot parse Array first character '{0}'", stream.Char)); } value.Clear(); var first = true; stream.SkipSpaces(); while (stream.Char != ']') { if (!first) { if (stream.Char != ',') { throw new Exception("Cannot parse array, no , (comma) found"); } stream.Next(); stream.SkipSpaces(); } var element = StringFactory.GetJElementFromJSON(stream); value.Add(element); stream.SkipSpaces(); first = false; } stream.Next(); }
private KeyValuePair <string, Element> ParseKeyValuePair(JStream stream) { //TODO: just temporary var stringKey = new StringElement(); stringKey.PopulateElement(stream); stream.SkipSpaces(); if (stream.Char != ':') { throw new Exception("Cannot parse object, not found :"); } stream.Next(); stream.SkipSpaces(); var key = stringKey.Value; var element = StringFactory.GetJElementFromJSON(stream); return(new KeyValuePair <string, Element>(key, element)); }