Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse JSON response

Tags:

json

ios

I wonder how could I parse JSON in iOS. notice I tried to use:

 NSError* error;
    NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData //1
                                                         options:kNilOptions 
                                                           error:&error];

however, i give me the following error:

"The operation couldn’t be completed. (Cocoa error 3840.)" (Badly formed object around character 310.) UserInfo=0x135460 {NSDebugDescription=Badly formed object around character 310.}

The JSON response I'm trying to parse is:

{"error":0,"token":"59188a107d705f8c51585d719769e0642ce98b79d86fdace30dbc58efba301cc","status":"200","messages":[{"update_time":2012-03-09 12:25:26.0,"seq":"21","lng":58.4236,"msg":"Bill We-Mark : Test","lat":23.5871}],"error_msg":""}

There is No char 310 here???!!!!

like image 538
user836026 Avatar asked Sep 26 '26 22:09

user836026


1 Answers

character 310 means the character at index 310.

Any way, your problem is here "update_time":2012-03-09 12:25:26.0. You have to add quotes: "update_time":"2012-03-09 12:25:26.0"?

like image 183
sch Avatar answered Sep 28 '26 12:09

sch