Your JSON is not well formed. You tell us that it is (white space and line breaks added for legibility purposes):
{
"id": "a1",
"session": "General",
"name": "Exhibitor Setup Begins",
"startTime": "0900",
"details": "9am Exhibitor Hall",
"png": "image",
"speaker1": "Johnson",
"speaker2": "Nelson",
"speaker3": ""
}{
"id": "b1",
"session": "General",
"name": "Conference Registration",
"startTime": "1000",
"details": "10am Noon Upper Level Lobby",
"png": "image",
"speaker1": "Jackson",
"speaker2": "",
"speaker3": ""
}
That's missing a comma between the two dictionary entries, and you're missing the [
and ]
that should wrap the JSON. If it's really an array of dictionary entries, it should be:
[
{
"id": "a1",
"session": "General",
"name": "Exhibitor Setup Begins",
"startTime": "0900",
"details": "9am Exhibitor Hall",
"png": "image",
"speaker1": "Johnson",
"speaker2": "Nelson",
"speaker3": ""
},
{
"id": "b1",
"session": "General",
"name": "Conference Registration",
"startTime": "1000",
"details": "10am Noon Upper Level Lobby",
"png": "image",
"speaker1": "Jackson",
"speaker2": "",
"speaker3": ""
}
]
If you want to check your JSON, you can visit http://jsonlint.com. Also, if you checked the error
object returned by JSONObjectWithData
, it would have pointed you in the right direction.
You should look how this JSON was generated. It looks like it must have been manually generated. If you were generating this from a PHP page, for example, you should use json_encode
, for example, rather than manually generating the JSON.
By the way, you are trying to parse the result in didReceiveData
. You shouldn't try to parse until connectionDidFinishLoading
. Your didReceiveData
should merely append the data
to your NSMutableData
object. The parsing should be deferred until connectionDidFinishLoading
.