I have search results in JSON and I want to deserialize it into strongly typed objects
For example:
{
searchresult: {
resultscount: 15,
results: [
{
resultnumber: 1,
values: [
{
key: "bookid",
value: 1424
},
{
key: "name",
value: "C# in depth"
},
]
}
]
}
}
And I have this POCO
public class Book {
public int BookId { get; set; }
public string Name { get; set; }
}
I want to get a list of books. Yes, I can write my own custom deserializer for this case, but I want to use a default deserializer.
Is it possible to do something like that?
IEnumerable<Book> books = JsonConvert.DeserializeObject<IEnumerable<Book>>(json);