C#转换JSON结果

时间:2012-07-25 23:49:58

标签: json parsing

我从 Box.com 获取此JSON:

{
    "total_count": 2,
    "entries": [
        {
            "type": "file",
            "id": "2615240421",
            "sequence_id": "0",
            "name": "successful file upload.png",
            "description": null,
            "size": 19586,
            "path": "/Hey Hey Whats Goin On/successful file upload.png",
            "path_id": "/316877053/2615240421",
            "created_at": "2012-07-11T11:54:21-07:00",
            "modified_at": "2012-07-11T11:54:21-07:00",
            "etag": null,
            "created_by": {
                "type": "user",
                "id": "181757341",
                "name": "sean test",
                "login": "sean+test@box.com"
            },
            "modified_by": {
                "type": "user",
                "id": "181757341",
                "name": "sean test",
                "login": "sean+test@box.com"
            },
            "owned_by": {
                "type": "user",
                "id": "181757341",
                "name": "sean test",
                "login": "sean+test@box.com"
            },
            "shared_link": null,
            "parent": {
                "type": "folder",
                "id": "316877053",
                "sequence_id": "0",
                "name": "Hey Hey Whats Goin On"
            }
        },
        {
            "type": "file",
            "id": "2615240431",
            "sequence_id": "0",
            "name": "a whole lot of shit just happenedjson.png",
            "description": null,
            "size": 128063,
            "path": "/Hey Hey Whats Goin On/a whole lot of shit just happenedjson.png",
            "path_id": "/316877053/2615240431",
            "created_at": "2012-07-11T11:54:21-07:00",
            "modified_at": "2012-07-11T11:54:21-07:00",
            "sha1": null,
            "created_by": {
                "type": "user",
                "id": "181757341",
                "name": "sean test",
                "login": "sean+test@box.com"
            },
            "modified_by": {
                "type": "user",
                "id": "181757341",
                "name": "sean test",
                "login": "sean+test@box.com"
            },
            "owned_by": {
                "type": "user",
                "id": "181757341",
                "name": "sean test",
                "login": "sean+test@box.com"
            },
            "shared_link": null,
            "parent": {
                "type": "folder",
                "id": "316877053",
                "sequence_id": "0",
                "name": "Hey Hey Whats Goin On"
            }
        }
    ]
}

我需要获取每个文件的修改信息。不知道如何在.NET中执行此操作。我习惯于解析XML。我在Stack上看到了一些例子,但它们通常都是浅物体。不确定更深层的物体。

帮助?

由于

1 个答案:

答案 0 :(得分:0)

我只想使用内置的JavaScriptSerializer class。您可以将JSON反序列化为特定类型或“即时”类型,然后您可以“遍历”。