Preventing crashes: JSON Parsers & Null entries!

How many times you got to parse a backend response, and tested if a given value is != nil?. Well, as it turns out, many parsers (such as JSONKit) will parse ‘null’ values into an instance of NSNull. That might cause a crash… unless you write eeeverywhere… ‘!= nil && != [NSNull null]’.

So… a good idea would be to implement an NSDictionary extention, to do that. Right?.
The method would look like this:
[cc lang=”objc”]
– (id)objectForKeyNotNull:(id)key 
{
    id object = [self objectForKey:key];
    if (object == [NSNull null])
    {
        return nil;
    }
    else
    {
        return object;
    }
}[/cc]