views:

222

answers:

2

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

A: 

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" 
} 
]
Orbit
A: 

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.

nicktmro