Wednesday, 2 October 2013

NSJSONSerialization - What is the proper value to specify no NSJSONWritingOptions for dataWithJSONObject:options:error:?

NSJSONSerialization - What is the proper value to specify no
NSJSONWritingOptions for dataWithJSONObject:options:error:?

Apple's documentation has the NSJSONWritingOptions enum with one constant
defined: NSJSONWritingPrettyPrinted, and says that "If this option is not
set, the most compact possible JSON representation is generated."
I definitely want the most compact JSON representation.
My question is: what is the proper value to pass the
dataWithJSONObject:options:error: function if I don't want pretty printed,
and why?
The NSJSONWritingOptions enum is defined as
enum { NSJSONWritingPrettyPrinted = (1UL << 0) }; typedef NSUInteger
NSJSONWritingOptions;
I have read in a different post that 0 should be passed, but with no
further explanation as to why it shouldn't be nil.

No comments:

Post a Comment