I have a JSON object that is coming from a webserver.
The log is something like this:
{
\"status\":\"success\",
\"Us
I usually do it like this:
Assuma I have a data model for the user, and it has an NSString property called email, fetched from a JSON dict. If the email field is used inside the application, converting it to empty string prevents possible crashes:
- (id)initWithJSONDictionary:(NSDictionary *)dictionary{
//Initializer, other properties etc...
id usersmail = [[dictionary objectForKey:@"email"] copy];
_email = ( usersmail && usersmail != (id)[NSNull null] )? [usersmail copy] : [[NSString alloc]initWithString:@""];
}