【问题标题】:Need help parsing JSON on iPhone using json-framework需要帮助在 iPhone 上使用 json-framework 解析 JSON
【发布时间】:2010-07-03 01:44:19
【问题描述】:

我目前正在使用 json-framework 并且需要一些帮助,尽管我需要解析一些我从服务器获取的 JSON。这是 JSON 的外观: 就像我说的,我已经安装了 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"
    }
]

【问题讨论】:

    标签: iphone json parsing


    【解决方案1】:

    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" 
    } 
    ]
    

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2011-03-17
        • 2018-12-11
        • 1970-01-01
        • 1970-01-01
        • 2016-07-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多