Json.Net의 Json2Linq를 사용하여 Json 응답을 필터링하려고하는데 필터링 중에 "Newtonsoft.Json.Linq.JProperty에서 하위 값에 액세스 할 수 없습니다."라는 오류가 발생했습니다. 아래의 C#에 내 코드입니다Filter Json이 Facebook에서 응답
JObject rss = JObject.Parse(userJson);
try
{
var FriendsLikes = from c in rss["friends"].First()["data"]
.SelectMany(l => l["likes"]
.Select(d => d["data"]).Where(r => r["id"].Value<string>() == "475729939105078")).Values<string>()
group c by c into g
orderby g.Count() descending
select new { FriendsLikes = g.Key };
foreach (var item in FriendsLikes)
{
System.Diagnostics.Debug.WriteLine(item.FriendsLikes);
}
}
catch (System.Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
}
페이스 북 JSON 응답
{
"id": "999999999084775",
"name": "Alex Xx",
"first_name": "Alex",
"last_name": "Xx",
"gender": "male",
"link": "https://www.facebook.com/app_scoped_user_id/101999999999999/",
"locale": "en_US",
"email": "[email protected]",
"picture": {
"data": {
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/18341660_101370733774524_7009999999999957463_n.jpg?oh=ec8675dfe23bbda00b6048647af62875&oe=59C0F7DF",
"is_silhouette": false
}
},
"friends": {
"data": [{
"id": "10213045626997937",
"name": "Jayson Raga",
"first_name": "Jayson",
"last_name": "Ragasa",
"gender": "male",
"link": "https://www.facebook.com/app_scoped_user_id/10213045626997937/",
"locale": "en_US",
"picture": {
"data": {
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/16114608_10211941851924250_4611916174586601978_n.jpg?oh=de4c0a7839e7e9e7ef6e29e18b885ef898&oe=59A99999",
"is_silhouette": false
}
},
"likes": {
"data": [{
"live_videos": {
"data": [{
"from": {
"name": "MyBeat",
"id": "475728822105078"
},
"permalink_url": "/MyBeat/videos/1283448691726531/",
"description": "@[141752355816253]:behind the decks live",
"creation_time": "2016-07-03T17:20:49+0000",
"id": "1261428671666530"
}]
},
"id": "475723939105078"
}]
}
}]
},
}
내 코드에서 내 목표는 같은 모든 내 친구들을 필터링 및 ID에서 모든 좋아하는 반환하는 것입니다: 475723939105078
를