Taking into consideration performance and readability, how should dates be encoded in JSON for use in iPhone applications? The ideal encoding would work with NSDate easily, but also be future proofed for use in a web based back end (i.e. Not using an API exclusive to the iPhone, something crossplatform). Here are some encodings I have been considering:
# UNIX Epoc based integer encoding
{"Date":123456789}
# ISO 8601 String format
{"Date":"2011-03-25T20:00Z"}
Will the parsing of the ISO 8601 string impact performance too much when thousands of dates are processed? Is the performance hit too low to matter when compared to Epoc? Is there an encoding missing that accomplishes the mentioned requirements?
I've always used Unix epoch based encoding when I have control of the server stack. The pros outweigh the cons for my use cases
epoch pros
epoch cons
ISO pros
ISO cons
ISO parsing is not hard, but you must check yourself on your own implementation. Cocoa doesn't have the fastest string parser. I have to believe that it will be noticeably slower (likely more than 2x).