I'm working with Facebook API and it's search method returns a JSON response like this:
{
"data": [
{
"id": "1",
"message": "Heck of a babysitter...",
"name": "Baby eating a watermelon",
"type": "video"
},
{
"id": "2",
"message": "Great Produce Deals",
"type": "status"
}
]
}
I have a class structure similar to this:
[DataContract]
public class Item
{
[DataMember(Name = "id")]
public string Id { get; set; }
}
[DataContract]
public class Status : Item
{
[DataMember(Name = "message")]
public string Message { get; set; }
}
[DataContract]
public class Video : Item
{
[DataMember(Name = "string")]
public string Name { get; set; }
[DataMember(Name = "message")]
public string Message { get; set; }
}
[DataContract]
public class SearchResults
{
[DataMember(Name = "data")]
public List<Item> Results { get; set; }
}
How can I use correct subclass based on that type
attribute?