I have some objects which I'm sending to a server as JSON, in the request body, for a POST request. My question relates to boolean properties.
Say I have this property in an object I'm sending as JSON:
@property (nonatomic) BOOL exported;
By default, RestKit sends the boolean as either 1
or 0
in JSON. How can I setup RestKit so that all BOOLs are sent as true
or false
(which is the JSON boolean type).
Funnily enough, when going the other way, from JSON true
or false
to the BOOL property, RestKit reads the JSON true/false
just fine, appropriately setting the property.
Alternatively; you could make it a bool instead of a BOOL and restkit will parse it properly.
@property (nonatomic) bool exported;
The reason it handles it properly in a read is that bool's are inherently just 1 or 0... so Restkit is smart enough to convert it to a BOOL.
Source type :NSCFBoolean
Destination type : NSString
Discussion: Boolean literals true and false parsed from JSON are mapped to NSString properties as @"true" and @"false"
Source :See This table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With