需要帮助使用json-framework在iPhone上解析JSON

时间:2010-07-03 01:44:19

标签: iphone json parsing

我目前正在使用json-framework并需要一些帮助,虽然解析了我从服务器获取的一些JSON。以下是JSON的外观: 就像我说我已经安装了json框架但我无法弄清楚如何实际解析它。有人可以给我看看吗?谢谢!

[
    {
    "id":"0",
    "name":"name",
    "info":"This is info",
    "tags":
        [
            {
            "id":"36",
            "tag":"test tag",
            },
            {
            "id":"37",
            "tag":" tag 2",
            }
        ],
    "other":"nil"
    },
    {
    "id":"1",
    "name":"name",
    "info":"This is info",
    "tags":
        [
            {
            "id":"36",
            "tag":"test tag",
            },
            {
            "id":"37",
            "tag":" tag 2",
            }
        ],
    "other":"nil"
    }
]

2 个答案:

答案 0 :(得分:0)

jsonlint.com会帮助你验证,我不相信你想要尾随逗号。 json-framework实现了一个严格的解析器。

[
{
    "id": "0",
    "name": "name",
    "info": "This is info",
    "tags": [
        {
            "id": "36",
            "tag": "test tag"
        },
        {
            "id": "37",
            "tag": " tag 2"
        }
    ],
    "other": "nil" 
},
{
    "id": "1",
    "name": "name",
    "info": "This is info",
    "tags": [
        {
            "id": "36",
            "tag": "test tag"
        },
        {
            "id": "37",
            "tag": " tag 2"
        } 
    ],
    "other": "nil" 
} 
]

答案 1 :(得分:0)

查看json-framework下载中的Examples.m文件。也可以here。 该API可用here

在进行解析时,您可能最终会使用NSString和NSObject类别。