Jun 18, 2009 at 1:44 PM
Edited Jun 18, 2009 at 1:44 PM
Is it possible to mix LINQ and JsonConverters?
I'm trying to do something like this:
var jsonReader = new JsonTextReader(new StringReader(data));
var jsonSerializer = new JsonSerializer();
var json = (JObject) jsonSerializer.Deserialize(jsonReader);
Revision r = json.Value<Revision>("base");
Where Revision is a class that has a JsonConverter specified:
public class Revision ...
It fails with an invalid cast, apparently not using the JsonConverter specified on the class.
I can work around it by converting "base" back to a JSON string and then deserializing that with JsonConvert.DeserializeObject, but that seems unnecessarily clunky.
Thanks for any guidance!