How to deserialize a JObject to .NET object

I happily use the Newtonsoft JSON library.
For example, I would create a JObject from a .NET object, in this case an instance of Exception (might or might not be a subclass)

if (result is Exception)
    var jobjectInstance = JObject.FromObject(result);

now I know the library can deserialize JSON text (i.e. a string) to an object

// only works for text (string)
Exception exception = JsonConvert.DeserializeObject<Exception>(jsontext); 

but what I am looking for is:

// now i do already have an JObject instance
Exception exception = jobjectInstance.????

Well it is clear that I can go from on JObject back to JSON text and then use the deserialize functionality, but that seems backwards to me.

3 Answers
3

Leave a Comment