简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM