/// <summary> /// Reads the JSON representation of the object. /// </summary> /// <param name="reader">The <see cref="Newtonsoft.Json.JsonReader"/> to read from.</param> /// <param name="objectType">The <see cref="System.Type"/> of the object.</param> /// <param name="existingValue">The existing value of object being read.</param> /// <param name="serializer">The calling serializer.</param> /// <returns>The object value.</returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { long ms; switch(reader.TokenType) { case JsonToken.String: ms = long.Parse(reader.Value.ToString()); break; case JsonToken.Integer: ms = (long)reader.Value; break; default: throw new InvalidOperationException("This object is not a timestamp"); } return InternalUtils.GetUnixTimeMs(ms); }