Tag Archives: json

Deserializing interface properties with Json.NET

Newtonsoft.json nuget package allows you to serialize and deserialize objects into json.

Install-Package Newtonsoft.Json

In this post I am going to show you how to handle a scenario where your models are structured after interfaces and you need to implement them, but then you also need to know what the concrete type is to be able to deserialize your json.

Some basic operations from Newtonsoft.Json are:

You can convert an object to Json using:


And convert it back using:

YourType x = JsonConvert.DeserializeObject<YourType>(json);

It also supports dynamic objects

dynamic dyn = JsonConvert.DeserializeObject(json);
// dyn.Stuff

Continue reading