How to parse JSON response

I wonder how one can parse JSON in iOS. the notification I tried to use:

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

      

however, I am giving the following error:

"The operation could not be performed. (Cocoa error 3840.)" (Badly formed object around symbol 310.) UserInfo = 0x135460 {NSDebugDescription = Badly formed object around symbol 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 ":" "}

No char 310 here ??? !!!!

+3


source to share


2 answers


<310> character 310 means character with index 310.

Anyway, your problem is here "update_time":2012-03-09 12:25:26.0

. You must add quotes "update_time":"2012-03-09 12:25:26.0"

:?



+10


source


Do not be offended, are you sure that the line you are parsing? Also, I would put that date in quotes to see what happens. Best practice is to quote all literal values. If you can't manage JSON, strict email is ok.



+2


source







All Articles