Code Project, I have a `Json` retrieved from facebook api call. As here below:
{"data":[{"id":"1264038093655465_1274837905908817","from":{"id":"1264038093655465","name":"Naser Dostdar","picture":{"data":{"url":"https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/15178246_1239033029489305_8223781070150796361_n.jpg?oh=cca928f11f42edaac99e72be286161c3&oe=59245409"}}},"message":"امروز یک روز فوق العاده بود، یک دوست و همکارم را بعد از مدت دو سال دیدم!\nتشکر نادر صاحب بخاطر مهمانی\n@ Baser Nader","type":"status","created_time":"2017-01-05T14:36:47+0000","likes":{"data":[{"id":"10154729171332597","name":"Sayed Zubair Hashimi"},{"id":"1821833754756701","name":"Junaid Walizada"},{"id":"648198542030750","name":"Mohib Akhondzada"},{"id":"360411140983593","name":"Za Beah"},{"id":"10153975726331432","name":"Baser Nader"},{"id":"444098429312431","name":"Abasin Deniz"}]
Though I've shortened the Json array but the question remains the same. The Json array is checked to be valid on www.jsonlint.com.
So the Question is how can I De-Serialize this Json array and then pass it my view model which is here as below:
public class Datum2
{
public string name { get; set; }
public string pic_large { get; set; }
public string id { get; set; }
}
public class Likes
{
public List<Datum2> data { get; set; }
}
public class Datum
{
public string id { get; set; }
public Likes likes { get; set; }
}
public class RootObject
{
public List<Datum> data { get; set; }
}
What I have tried:
dynamic myFeed = await fb.GetTaskAsync(
("me/feed?fields=likes{{name,pic_large}}")
.GraphAPICall(appsecret_proof));
I tried to parse dynamic myFeed to string as follow:
string json = myFeed.data.ToString();
Then JsonConvert to De-Serialize the Json into RootObject Class as shown here:
var result = JsonConvert.DeserializeObject<List<RootObject>>(json);
But while in Debugging mode in always see that the field properties in Datum2 class is always null.