Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Net解析所有消息的Facebook图形JSON_C#_Asp.net Mvc_Facebook Graph Api_Json.net - Fatal编程技术网

C# Net解析所有消息的Facebook图形JSON

C# Net解析所有消息的Facebook图形JSON,c#,asp.net-mvc,facebook-graph-api,json.net,C#,Asp.net Mvc,Facebook Graph Api,Json.net,使用JSON.Net()和以下代码: @using Newtonsoft.Json; @using Newtonsoft.Json.Linq; @{ var url = "https://graph.facebook.com/v2.2/me&fields=id%2Cname%2Cposts.limit(3)&format=json&method=get&pretty=0&suppress_http_code=1"; var syncC

使用JSON.Net()和以下代码:

@using Newtonsoft.Json;
@using Newtonsoft.Json.Linq;


@{

    var url = "https://graph.facebook.com/v2.2/me&fields=id%2Cname%2Cposts.limit(3)&format=json&method=get&pretty=0&suppress_http_code=1";
    var syncClient = new WebClient();
    var content = syncClient.DownloadString(url);

    JObject facebook = JObject.Parse(content);

    //To-Do: Get all messages as list<string> using LINQ for JSON
    // Ex:  IList<string> allDrives = o["Drives"].Select(t => (string)t).ToList();




}
@使用Newtonsoft.Json;
@使用Newtonsoft.Json.Linq;
@{
变量url=”https://graph.facebook.com/v2.2/me&fields=id%2Cname%2Cposts.limit(3) &format=json&method=get&pretty=0&suppress\u http\u code=1”;
var syncClient=new WebClient();
var content=syncClient.DownloadString(url);
JObject facebook=JObject.Parse(内容);
//要做的事情:使用linqforjson获取所有消息作为列表
//例如:IList allDrives=o[“Drives”].Select(t=>(string)t.ToList();
}
如果给定以下JSON格式(),如何获取所有消息的列表


提前谢谢

选择所有消息作为字符串(无错误检查):


非常好,谢谢!我一定会在错误检查中进行构建。这是查询数据+1的好方法,这段代码正在运行并且很酷,我一直在寻找类似于w的东西,同时,非常感谢,答案也在运行
var arr = ((JArray) obj["posts"]["data"]).Select(e => (string) ((JValue) e["message"]).Value).ToList();