0

I have found a few ways to parse JSON in Objective-C:

Both of these methods work great, however my only problem is that when an error occurs, I would like more details than the error message. Specifically, I would like to know the line number and column that the error occurs on (both SBJSON and NSJSONSerialization do return errors, however the errors seem to only contain a Message with no more details).

Any suggestions on how I can get more details on the error that occurs when processing JSON?

Kyle
  • 17,317
  • 32
  • 140
  • 246

1 Answers1

1

I found that when receiving an error from NSJsonSerialization, I am able to get more details about the error with the following code:

NSString * details = [[error userInfo] objectForKey: @"NSDebugDescription"];

Which gives me the character index of where the error happens. From this I was able to figure out the line.

Kyle
  • 17,317
  • 32
  • 140
  • 246