我如何解析JSON? [英] How do i parse json?

查看:152
本文介绍了我如何解析JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Newtonsoft JSON库解析JSON的,但我不知道如何使用它。我用解析的JObject字符串。当我输出的即时窗口JObject实例的值,我得到这样的: -

I am using Newtonsoft Json library to parse json but i don't know how to use it. I parsed the string using JObject. When i output the value of JObject instance in immediate window i get this :-

json
{
  "data": [
    {
      "id": "id",
      "from": {
        "name": "name",
        "id": "someotherid"
      },
      "name": "pic",
      "description": "desc",
      "link": "linktosite",
      "privacy": "everyone",
      "count": 1,
      "type": "normal",
      "created_time": "2010-10-22T14:54:32+0000",
      "updated_time": "2010-10-22T14:55:41+0000"
    },
    {
      "id": "id2",
      "from": {
        "name": "name",
        "id": "someotherid"
      },
      "name": "Profile Pictures",
      "link": "link",
      "privacy": "everyone",
      "count": 6,
      "type": "profile",
      "created_time": "2010-10-12T14:27:58+0000",
      "updated_time": "2011-01-01T18:38:14+0000"
    },
    {
      "id": "id3",
      "from": {
        "name": "name",
        "id": "829741958"
      },
      "name": "T",
      "link": "link",
      "privacy": "everyone",
      "count": 5,
      "type": "normal",
      "created_time": "2010-05-01T03:03:39+0000",
      "updated_time": "2010-05-01T03:19:13+0000",
      "comments": {
        "data": [
          {
            "id": "id",
            "from": null,
            "message": "message",
            "created_time": "2010-08-28T18:27:10+0000",
            "likes": 1
          }
        ]
      }
    }
  ],
  "paging": {
    "previous": "paginglink",
    "next": "otherpaginglink"
  }
}

    Count: 2
    Type: Object

我应该再做些什么有从这个jobject值?

What should i do further to have the values from this jobject?

推荐答案

我个人比较喜欢的的JavaScriptSerializer 在.NET环境中使用JSON的使用。默认情况下,将返回一个词典的结果,但可用于在解析到自定义对象(或者也可以利用动态数据类型)。

I personally prefer the JavaScriptSerializer for use with JSON in the .NET environment. By default it will return a Dictionary result, but can be used to parse in to a custom object (or you could make use of the dynamic datatype).

上等等一些其他职位与JSON和放大器; JavaScript的串行器作为话题

这篇关于我如何解析JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆