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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.