objective c - Replacing nulls with empty string from JSON response not working in iOS -
I have used code below to replace nulls with json feedback with empty string, but it is not working . Please help me to fix this problem, I'm disabling of many scenarios and server response in app crash.
code:
- (NSMutableDictionary *) recursive: (NSMutableDictionary *) dictionary attachment {NSMutableDictionary * dictionary = [[NSMUTABLEXAd ALLOC] initWithDictionary: dictionaryRespens]; ({Dictionary allKeys] in NSString * key {id nullString = [dictionary objectForKey: key]; If ([nullString isKindOfClass: [nsiteware class]]) {[self-recursive: (NSMutableDictionary * nullString]; } And if ([nullString isKindOfClass: [NSArray class]]) {for (int i = 0; i <[nullString count]; i ++) {id nullstr = [nullString object endindex x: i]; If ([nullstr hackedoffclaim: [nsysta class]]) {[self recursive: (nsmutbenxide * nullrust]; }}} And {if ((NSString *) nullString == (ID) [NSNull null]) [Dictionary set value: @ "" key: key]; }} Return dictionary; }
Try this:
- ( NSMutableDictionary *) Recursive tap revoke: (NSMutableDictionary *) Dictionary Reset {NSMutableDictionary * Dictionary = [dictionary resuscitationable changeable coop]; NSString * nullString = @ ""; ({Dictionary allKeys] in NSString * key {id value = dictionary [key]; If ([value iskindoffclass: [nsfeite class]]) {dictionary [key] = [self-recursive removal (nsmutabxxscreen *) value]; } And if ((value iskindoffclass: [nsarra class]]) {nmutibalearre * newairre = [value incorrect coop]; For (int i = 0; i
Edited:
I have found a problem in my reply, and now it is decided
This is the check code:
< Pre> NSDictionary *** dict = @ {@ "1": @ {@ "1.1": @ "value", @ "1.2": [NSNull null]}, @ 2 ": @ [@" 2.1 ", @ {@ "2.2.1": @ "wal", @ "2.2.2": [NSNL tap]}], @ "3": [NSEL's key ]}; Dict = [self recursiveNullRemove: dict];
Comments
Post a Comment