I read a lot of articles about JSON to C# conversion but I have one specific problem. I'm trying to convert JSON from Http response to C# object of NewsResult type with following line of code :
var newsResult = await response.Content.ReadAsAsync<NewsResult>();
This code works in most of cases and map automatically JSON data to hierarchy of C# objects, but in one case REST returns following JSON:
{
"result": {
"1": {
"id": 1,
"title": "title01"
},
"2": {
"id": 2,
"title": "title02"
},
...
Resulting C# class should look like this
public class NewsResult
{
public ICollection<News> Result { get; set; }
}
I have trouble to map this JSON to some C# object hierarchy automatically. Do you have any idea please how to resolve this problem? I would prefer C# code that I mentioned but I would try another approach if it will be needed. One more info: I can't change REST service. Thank you.