Question

Scenario: Ruby on Rails app that returns JSON to an iOS application using json-framework to parse the JSON and push the data onto Core Data objects.

Problem: Many of attributes returned from in the JSON can be null and a large number of them are not simple strings (e.g., they are DateTimes with timezones, integers, floats, etc...).

Question: What is the most efficient way to handle such JSON? Does json-framework (or something else perhaps) have any helpers to make parsing such data easier ... -or- ... do I simply gotta do [NSNull null] checks on each and every attribute and if not null do the appropriate conversion to NSDate, NSNumber or whatever?

Thanks -wg

Was it helpful?

Solution

With regards to handling Null values, I suggest making use of a category on NSDictionary:

TouchJSON, dealing with NSNull

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top