Objective-C enforces the conversion of a BOOL
to an NSNumber
for storage in an NSDictionary
which is converted to JSON by NSJSONSerialization
.
Is it possible to write literal boolean values (true
or false
with no string quotations) to JSON instead of 0
and 1
? This would make interactions with servers that don't support 0 or 1 a lot easier.
For an example, if I had a boolean value being saved in an NSDictionary
using @YES
/@NO
, [NSNumber numberWithBool:BOOL]
, etc. NSJSONSerialization
would output it like this:
{
"excludes": 1
}
But I want it to look like this:
{
"excludes": true
}
Any ideas or solutions? Android makes this much easier.