当我使用json Web服务并将值存储在NSMutablearray中时,却得到了Null响应。现在我想删除该null值并将其替换为空。任何人都可以帮助我解决此错误。
(
{
Aadhar =1123323244;
AddressProofCopy = "<null>";
Advertisement = "<null>";
AgreementCopy = "<null>";
ApCity = ggg;
ApDistrict = g;
ApDoorNo = g;
ApFGFirstName = v;
ApFGSurName = g;
ApGender = F;
ApPIN = 12323;
ApStreet = h;
AppStatus = "<null>";
ApplRefStageStatus = N;
ApplicantFirstName = g;
ApplicantPhoto = "<null>";
ApplicantSurName = g;
ApplicationDate = "2018-09-06T00:00:00.000Z";
ApplicationType = New;
BuldingType = "<null>";
District = 132424;
DistrictId = 11;
DocVerifiedBy = "<null>";
DocVerifiedDate = "<null>";
DocVerifiedMessage = "<null>";
DocVerifiedStatus = "<null>";
}
)
最佳答案
请验证此链接。https://github.com/bismasaeed00/NullReplacer它对我来说工作正常。
尝试这个..
#import "NSArray+NullReplacement.h"
#import "NSDictionary+NullReplacement.h"
之后,根据您的字典/数组JSON响应,使用以下代码行,
NSArray *newvalue = [yourarrayresponse arrayByReplacingNullsWithBlanks];
要么
NSDictionary *newvalue = [yourdictionary dictionaryByReplacingNullsWithBlanks];
如果您遇到任何错误,只需添加
#import "NSArray+NullReplacement.h"
在NSDictionary + NullReplacement类和
#import "NSDictionary+NullReplacement.h"
在NSDictionary + NullReplacement类文件中。