It can't be nil
because it's an NSUInteger
. So, you should pass 0
, which represents that the option is not set.
NSJSONSerialization - What is the proper value to specify no NSJSONWritingOptions for dataWithJSONObject:options:error:?
-
30-06-2022 - |
Question
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.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow