【问题标题】:Json deserialization [duplicate]Json反序列化[重复]
【发布时间】:2013-05-22 19:49:55
【问题描述】:

通过这段代码,我尝试读取summary-> unseen_count的值,但我不能

FacebookClient fb = new FacebookClient(Settings.Default["token"].ToString());

        try
        {
            dynamic FriendList = fb.Get("/me/notifications");

            int count = (int)FriendList.data.Count;

            for (int i = 0; i < count; i++)
            {
                textBox1.Text = FriendList.data[i].summary.unseen_count;
            }
        }
        catch
        {

        }

返回json数据:

{
       "data": [
          {
             "id": "notif_1000XXXX",    
              "etc"...         
          }
       ],
       "paging": {},

       "summary": {
          "unseen_count": 2,
          "updated_time": "2013-05-22T18:39:00+0000"
       }
    }

你能帮帮我吗?我一直不明白它是如何工作的 json

【问题讨论】:

  • 这是一个不同的东西不是一个列表
  • 返回 unsee_count 值

标签: c# json


【解决方案1】:

看起来 summary 不是数据的子节点;您是否尝试过以下方法(在 for 循环之外)?

textBox1.Text = FriendList.summary.unseen_count;

【讨论】:

  • 我试过不行
  • 您是否尝试过在调试器暂停的情况下检查 FriendList 对象?设置断点并深入挖掘。
猜你喜欢
  • 1970-01-01
  • 2019-06-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-11
  • 2019-09-27
  • 2021-11-27
  • 1970-01-01
相关资源
最近更新 更多