I'm making an awesome iPhone app which searches for YouTube videos using the JSON API. However, Google is lazy so they just transformed the ATOM feed into JSON. Things look like this:
feed->entry[0]->author[0]->name->$t
This means that getting the information out of the NSArray is difficult, as I need to get a value of a key of an object of an array of an object of an array of an object of a key.
To check if the structure is correct, I can choose two things:
- Use a huge amount of code for each item I want to check if the JSON was correct.
- Wrap everything in a @try block.
I'd like to choose the second one. The problem is that some time ago I read that this is bad practice. Is it? And if so, is there a shorter way to validate the NSArrays en NSDictionaries? My app may never crash, not even if the user remover the processor at runtime, so not checking at all is not an option.
Can you please help me? Thanks.