├── NSNull+JSON.h └── NSNull+JSON.m /NSNull+JSON.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNull+JSON.h 3 | // JingZhenGu 4 | // 5 | // Created by 杜维欣 on 15/10/30. 6 | // Copyright © 2015年 Mars. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSNull (JSON) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /NSNull+JSON.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNull+JSON.m 3 | // JingZhenGu 4 | // 5 | // Created by 杜维欣 on 15/10/30. 6 | // Copyright © 2015年 Mars. All rights reserved. 7 | // 8 | 9 | #import "NSNull+JSON.h" 10 | 11 | @implementation NSNull (JSON) 12 | - (NSUInteger)length { return 0; } 13 | 14 | - (NSInteger)integerValue { return 0; }; 15 | 16 | - (float)floatValue { return 0; }; 17 | 18 | - (NSString *)description { return @"0"; } 19 | 20 | - (NSArray *)componentsSeparatedByString:(NSString *)separator { return @[]; } 21 | 22 | - (id)objectForKey:(id)key { return nil; } 23 | 24 | - (BOOL)boolValue { return NO; } 25 | 26 | - (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet{ 27 | NSRange nullRange = {NSNotFound, 0}; 28 | return nullRange; 29 | } 30 | 31 | @end 32 | --------------------------------------------------------------------------------