/// <summary>
            /// Reads the json.
            /// </summary>
            /// <param name="reader">The reader.</param>
            /// <param name="objectType">Type of the object.</param>
            /// <param name="existingValue">The existing value.</param>
            /// <param name="serializer">The serializer.</param>
            /// <returns>A collection of <see cref="TwitterTrend"/> items.</returns>
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                TwitterTrendDictionary result = existingValue as TwitterTrendDictionary;

                if (result == null)
                {
                    result = new TwitterTrendDictionary();
                }

                int initialDepth = reader.Depth;

                if (reader.TokenType == JsonToken.StartArray)
                {
                    reader.Read();
                }

                while (reader.Read() && reader.Depth > initialDepth)
                {
                    if (reader.TokenType == JsonToken.PropertyName && reader.Depth == 1)
                    {
#if !SILVERLIGHT
                        switch ((string)reader.Value)
                        {
                        //TODO these two datetime converters don't seem to convert.
                        case "as_of":
                            reader.Read();
                            var c = new TwitterizerDateConverter();
                            result.AsOf = (DateTime)c.ReadJson(reader, typeof(DateTime), null, serializer);
                            continue;

                        case "trends":
                            reader.Read();
                            while (reader.Read() && reader.Depth >= 3)
                            {
                                if (reader.TokenType == JsonToken.PropertyName && reader.Depth == 3)
                                {
                                    try
                                    {
                                        var date = DateTime.ParseExact(reader.Value.ToString(), dateformats, CultureInfo.InvariantCulture, DateTimeStyles.None);
                                        result.Add(date, new TwitterTrendCollection());

                                        var converter = new TwitterTrendCollection.Converter();
                                        result[date] = (TwitterTrendCollection)converter.ReadJson(reader, typeof(TwitterTrendCollection), null, serializer);
                                    }
                                    catch
                                    {
                                        //bad date format
                                        return(null);
                                    }
                                }
                            }
                            continue;
                        }
#endif
                    }
                }
                return(result);
            }
            /// <summary>
            /// Reads the json.
            /// </summary>
            /// <param name="reader">The reader.</param>
            /// <param name="objectType">Type of the object.</param>
            /// <param name="existingValue">The existing value.</param>
            /// <param name="serializer">The serializer.</param>
            /// <returns>A collection of <see cref="TwitterTrend"/> items.</returns>
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                TwitterTrendCollection result = existingValue as TwitterTrendCollection;

                if (result == null)
                {
                    result = new TwitterTrendCollection();
                }

                int initialDepth = reader.Depth;

                while (reader.Read() && reader.Depth > initialDepth)
                {
                    if (reader.TokenType == JsonToken.PropertyName && reader.Depth == initialDepth + 2)
                    {
                        switch ((string)reader.Value)
                        {
                        //TODO these two datetime converters don't seem to convert.
                        case "as_of":
                            reader.Read();
                            var c = new TwitterizerDateConverter();
                            result.AsOf = (DateTime)c.ReadJson(reader, typeof(DateTime), null, serializer);
                            continue;

                        case "created_at":
                            reader.Read();
                            var d = new TwitterizerDateConverter();
                            result.CreatedAt = (DateTime)d.ReadJson(reader, typeof(DateTime), null, serializer);
                            continue;

                        case "locations":
                            reader.Read();
                            var e = new TwitterTrendLocationCollection.Converter();
                            result.Locations = (TwitterTrendLocationCollection)e.ReadJson(reader, typeof(TwitterTrendLocationCollection), null, serializer);
                            continue;
                        }
                    }
#if !SILVERLIGHT
                    if (reader.TokenType == JsonToken.StartObject && reader.Depth > initialDepth + 1)
#else
                    if (reader.TokenType == JsonToken.StartObject && reader.Depth > initialDepth + 2)
#endif
                    { result.Add(new TwitterTrend()); }

                    if (reader.TokenType == JsonToken.PropertyName)
                    {
                        switch ((string)reader.Value)
                        {
                        case "query":
                            reader.Read();
                            result[result.Count - 1].SearchQuery = (string)reader.Value;
                            continue;

                        case "name":
                            reader.Read();
                            result[result.Count - 1].Name = (string)reader.Value;
                            continue;

                        case "url":
                            reader.Read();
                            result[result.Count - 1].Address = (string)reader.Value;
                            continue;

                        case "promoted_content":
                            reader.Read();
                            result[result.Count - 1].PromotedContent = (string)reader.Value;
                            continue;

                        case "events":
                            reader.Read();
                            result[result.Count - 1].Events = (string)reader.Value;
                            continue;
                        }
                    }
                }

                return(result);
            }