Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.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# 使用C解析Json响应对象#_C#_Json_Facebook Graph Api - Fatal编程技术网

C# 使用C解析Json响应对象#

C# 使用C解析Json响应对象#,c#,json,facebook-graph-api,C#,Json,Facebook Graph Api,我通过发布到garph api获取facebook新闻提要的故事标签,如下所示,并获取json响应对象,其内容如下 { "from": { "category": "Recreation/sports website", "name": "Cricinfo", "id": "18429207554" }, "id": "18429207554_10152399273812555", "created_time": "2014-10-11T04:48:21+0000" } 现

我通过发布到garph api获取facebook新闻提要的故事标签,如下所示,并获取json响应对象,其内容如下

  {
 "from": {
  "category": "Recreation/sports website",
  "name": "Cricinfo",
  "id": "18429207554"
 },
"id": "18429207554_10152399273812555",
"created_time": "2014-10-11T04:48:21+0000"
}
现在我想用c#解析这个对象,以获得“name”字段值和“id”字段值……有人能告诉我如何解析json对象并获得值吗

 Newsfeed_Id = jsonObj1.Data([i]).id
                            Dim requestgetTags As WebRequest = _
          WebRequest.Create("https://graph.facebook.com/v2.1/" & Newsfeed_Id & "?fields=from,story_tags&access_token=" & _Obj.AccessToken & "")

                            requestgetTags.Credentials = CredentialCache.DefaultCredentials
                            Dim responsegetTags As WebResponse = requestgetTags.GetResponse()
                            Console.WriteLine(CType(responsegetTags, HttpWebResponse).StatusDescription)
                            Dim dataStreamgetTags As Stream = responsegetTags.GetResponseStream()
                            Dim readergetTags As New StreamReader(dataStreamgetTags)
                            Dim responseFromServergetTags As String = readergetTags.ReadToEnd()

首先,您的代码示例在VB上,而不是在C上。 但是,如果您仍然想在C#中解析json,下面是一个示例,说明如何解析json

var parsedResponse = JsonConvert.DeserializeObject<NewsFeed>(jsonResponse);
可能重复的
    public class NewsFeed
    {
      public string Id;
      public string CreatedTime;
      public Tag From;
    }

    public class Tag
    {
      [JsonConstructor]
      public NewsFeed(string category, string name, string id)
      {
         Category = category;
         Name = name;
         Id = id
      }
      public string Category;
      public string Name;
      public string Id;
    }