I have a json string that comes back as:
{ "expires_in": 300 }
I defined a class:
class Test
{
public DateTime ExpirationDate {get;set;}
}
Now I want to deserialize into that object, but want to convert the 300 to mean DateTime.Now.AddSeconds(300) so I did:
JsonConvert.DeserializeObject<Test>("{ \"expires_in\": 300 }");
So I tried:
class Test
{
[JsonProperty("expires_in", ItemConverterType=typeof(TestConverter))]
public DateTime ExpirationDate {get;set;}
}
But it never seems to get into the converter. Am I missing something?
Converter is just stubbed out:
class TestConvert : JsonConverter
{
public override bool CanConvert(Type objectType)
{
throw new NotImplementedException();
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}