You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
我先是使用字典转模型,中间因为模型中的属性名和JSON中的key不一致,进行转化。拿到模型后,再把模型转字典,这时候发现得到的字典里面的属性名变成JSON中的key而不是我模型中正确的属性名。通过断点,发现问题出现在: - (id)yy_modelToJSONObject { /* Apple said: The top level object is an NSArray or NSDictionary. All objects are instances of NSString, NSNumber, NSArray, NSDictionary, or NSNull. All dictionary keys are instances of NSString. Numbers are not NaN or infinity. */ id jsonObject = ModelToJSONObjectRecursive(self); if ([jsonObject isKindOfClass:[NSArray class]]) return jsonObject; if ([jsonObject isKindOfClass:[NSDictionary class]]) return jsonObject; return nil; }
在这个方法中传过去的self中属性名是正确的,在 id jsonObject = ModelToJSONObjectRecursive(self);之后,拿到的jsonObject中属性名就变成了之前JSON中的key值
The text was updated successfully, but these errors were encountered:
我先是使用字典转模型,中间因为模型中的属性名和JSON中的key不一致,进行转化。拿到模型后,再把模型转字典,这时候发现得到的字典里面的属性名变成JSON中的key而不是我模型中正确的属性名。通过断点,发现问题出现在:
- (id)yy_modelToJSONObject { /* Apple said: The top level object is an NSArray or NSDictionary. All objects are instances of NSString, NSNumber, NSArray, NSDictionary, or NSNull. All dictionary keys are instances of NSString. Numbers are not NaN or infinity. */ id jsonObject = ModelToJSONObjectRecursive(self); if ([jsonObject isKindOfClass:[NSArray class]]) return jsonObject; if ([jsonObject isKindOfClass:[NSDictionary class]]) return jsonObject; return nil; }
在这个方法中传过去的self中属性名是正确的,在
id jsonObject = ModelToJSONObjectRecursive(self);
之后,拿到的jsonObject中属性名就变成了之前JSON中的key值The text was updated successfully, but these errors were encountered: