objective-c json-framework: How to parse dates, nulls, and everything else in between efficiently?

StackOverflow https://stackoverflow.com/questions/7113995

문제

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

도움이 되었습니까?

해결책

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

TouchJSON, dealing with NSNull

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top