/// <summary> /// Skips the children of the current token. /// </summary> public void Skip() { if (TokenType == JsonToken.PropertyName) { Read(); } if (JsonTokenUtils.IsStartToken(TokenType)) { int depth = Depth; while (Read() && (depth < Depth)) { } } }
/// <summary> /// Reads the next JSON token from the stream as a <see cref="String"/>. /// </summary> /// <returns>A <see cref="String"/>. This method will return <c>null</c> at the end of an array.</returns> public virtual string ReadAsString() { JsonToken t = GetContentToken(); switch (t) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return(null); case JsonToken.String: return((string)Value); } if (JsonTokenUtils.IsPrimitiveToken(t)) { if (Value != null) { string s; if (Value is IFormattable) { s = ((IFormattable)Value).ToString(null, Culture); } else if (Value is Uri) { s = ((Uri)Value).OriginalString; } else { s = Value.ToString(); } SetToken(JsonToken.String, s, false); return(s); } } throw JsonReaderException.Create(this, string.Format("Error reading string. Unexpected token: {0}.", t)); }