使用yy_modelToJSONString这个方法的时候,有数据丢失的问题!!!
xtxh opened this issue · 1 comments
iOS platform
NSString* path = [[NSBundle mainBundle] pathForResource:@"user" ofType:@"json"];
NSData* jsonData = [NSData dataWithContentsOfFile:path];
NSDictionary* originJson = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
NSLog(@"originJson:%@",originJson);
ModelUserData* userData = [ModelUserData yy_modelWithJSON:jsonData];
NSLog(@"userData\ncode:%@,msg:%@,Info:%@,Info.parents:%@",userData.code,userData.msg,userData.userInfo,userData.userInfo.parents);
NSString* jsonString = [userData yy_modelToJSONString];
NSLog(@"userJson:%@",jsonString);
NSLog:
2018-01-29 16:56:42.829890+0800 TestCMModel[6039:523454] originJson:{
data = {
autograph = "Be the changes you want to see in the World!";
friends = (
{
age = 32;
autograph = "Hello world!";
gender = male;
isVIP = 0;
name = zhangsan;
parents = {
father = {
name = ZhangSI;
phone = 12345678901;
};
mother = {
name = WangLiu;
phone = 12345678902;
};
};
pets = (
{
color = white;
id = 1002;
petName = Caser;
petType = 2;
pid = 10021;
}
);
phone = 12345678904;
uid = 1002;
},
{
age = 23;
autograph = "Good good study, day day up!";
gender = female;
isVIP = 1;
name = lisi;
parents = {
father = {
name = LiQi;
phone = 12345678901;
};
mother = {
name = Lisiqi;
phone = 12345678902;
};
};
pets = "";
phone = 12345678905;
uid = 1003;
},
{
age = 19;
autograph = "Deep learning!";
gender = female;
isVIP = 0;
name = wangwu;
pets = (
{
color = white;
id = 1004;
petName = Alex;
petType = 3;
pid = 10041;
}
);
phone = 12345678906;
uid = 1004;
}
);
gender = male;
id = 1001;
isVIP = 1;
name = kipi;
parents = {
father = {
name = keYJ;
phone = 12345678901;
};
mother = {
name = ZL;
phone = 12345678902;
};
};
pets = (
{
color = white;
id = 1001;
petName = Jack;
petType = 0;
pid = 10011;
},
{
color = white;
id = 1001;
petName = Maliy;
petType = 1;
pid = 10012;
}
);
phone = 12345678903;
};
msg = success;
statusCode = 200;
}
2018-01-29 16:56:42.840752+0800 TestCMModel[6039:523454] userData
code:200,msg:success,Info:<ModelUser: 0x6040002868b0>,Info.parents:{
father = "<ModelUser: 0x604000287260>";
mother = "<ModelUser: 0x604000287210>";
}
2018-01-29 16:56:42.842992+0800 TestCMModel[6039:523454] userJson:{"statusCode":"200","msg":"success"}
经测试发现,如果实现了-(void)modelCustomTransformToDictionary:(NSMutableDictionary*)dic这个方法的话,再调用yy_modelToJSONString就会出现数据丢失的情况