一开始获得的数据
json解析用户信息数据 = {
id = 3;
"mem_address" = "";
"mem_agency" = "<null>";
"mem_agencyarea" = "<null>";
"mem_alipay" = "";
"mem_area" = 103580;
"mem_balance" = "8509.00";
"mem_bankcard" = "";
"mem_birthday" = "<null>";
"mem_city" = 100454;
"mem_createtime" = 1496297083;
"mem_curr_vip" = "<null>";
"mem_earnings1" = "0.00";
"mem_earnings2" = "0.00";
"mem_earnings3" = "0.00";
"mem_earnings4" = "0.00";
"mem_email" = "";
"mem_ice_balance" = "0.00";
"mem_identitycard" = 128989128312123;
"mem_integral" = 10998;
"mem_mobile" = 189289;
"mem_nickname" = "<null>";
"mem_prov" = 100026;
"mem_qq" = "";
"mem_qrcode" = "<null>";
"mem_realname" = WangWeiLin;
"mem_recommend" = "<null>";
"mem_sex" = 0;
"mem_superior" = 0;
"mem_username" = Fadykeane;
"mem_vip" = "<null>";
"mem_weixin" = "<null>";
"mem_ylh_mobile" = "";
"mem_ylh_username" = "";
}
需要处理一下,调用下面方法
-(NSDictionary *)dealWithNullData:(NSDictionary *)dic{
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:dic];
for (NSString *key in dict.allKeys) {
NSString *value = dict[key];
if ([value isEqual:[NSNull null]]) {
[dict setValue:@"" forKey:key];
}
}
return dict;
}
返回的数据
{
id = 3;
"mem_address" = "";
"mem_agency" = "";
"mem_agencyarea" = "";
"mem_alipay" = "";
"mem_area" = 103580;
"mem_balance" = "8509.00";
"mem_bankcard" = "";
"mem_birthday" = "";
"mem_city" = 100454;
"mem_createtime" = 1496297083;
"mem_curr_vip" = "";
"mem_earnings1" = "0.00";
"mem_earnings2" = "0.00";
"mem_earnings3" = "0.00";
"mem_earnings4" = "0.00";
"mem_email" = "";
"mem_ice_balance" = "0.00";
"mem_identitycard" = 128989128312123;
"mem_integral" = 10998;
"mem_mobile" = 189289;
"mem_nickname" = "";
"mem_prov" = 100026;
"mem_qq" = "";
"mem_qrcode" = "";
"mem_realname" = WangWeiLin;
"mem_recommend" = "";
"mem_sex" = 0;
"mem_superior" = 0;
"mem_username" = Fadykeane;
"mem_vip" = "";
"mem_weixin" = "";
"mem_ylh_mobile" = "";
"mem_ylh_username" = "";
}