/// <summary> /// Parses the dictionary. /// </summary> /// <param name="ignored">if set to <c>true</c> [ignored].</param> /// <param name="cache">The cache.</param> /// <param name="handler">The handler.</param> /// <param name="endToken">The end token.</param> /// <returns></returns> public object ParseDictionary(bool ignored, ReadCache cache, IDictionaryReadHandler handler, JsonToken endToken) { IDictionaryReader dr = (handler != null) ? handler.DictionaryReader() : dictionaryBuilder; object d = dr.Init(); while (jp.NextToken() != endToken) { object key = ParseVal(true, cache); if (key is Tag) { object val; jp.Read(); // advance to read value string tag = ((Tag)key).GetValue(); IReadHandler val_handler; if (TryGetHandler(tag, out val_handler)) { if (this.jp.TokenType == JsonToken.StartObject && val_handler is IDictionaryReadHandler) { // use map reader to decode value val = ParseDictionary(false, cache, (IDictionaryReadHandler)val_handler); } else if (this.jp.TokenType == JsonToken.StartArray && val_handler is IListReadHandler) { // use array reader to decode value val = ParseList(false, cache, (IListReadHandler)val_handler); } else { // read value and decode normally val = val_handler.FromRepresentation(ParseVal(false, cache)); } } else { // default decode val = this.Decode(tag, ParseVal(false, cache)); } jp.Read(); // advance to read end of object or array return(val); } else { jp.Read(); // advance to read value d = dr.Add(d, key, ParseVal(false, cache)); } } return(dr.Complete(d)); }