开发者

Need help parsing JSON on iPhone using json-framework

I'm currently using json-framework and need some help though parsing some JSON i'm getting from my server. Here is how开发者_高级运维 the JSON looks: Like I said I already have the json-framework installed but I can't figure out how to actually parse it. Can someone please show me? Thanks!

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


jsonlint.com will help you as far as validation, I don't believe you want the trailing commas. json-framework implements a strict parser.

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


Have a look at the Examples.m file in your json-framework download. Also available here. The API is available here.

You will probably end up using the NSString and NSObject categories when doing your parsing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜