【发布时间】:2017-05-19 05:50:24
【问题描述】:
如何使用 JSONModel 序列化自定义对象?
@property(nonatomic,strong) NSString<Optional> * tag_post_type;
@property(nonatomic,strong) NSString<Optional> * tag_users_type;
@property(nonatomic,strong) NSArray<Optional> * tags;
@property(nonatomic,strong) NSMutableArray<TagMediaModel*>* tag_posts;
@property(nonatomic,strong) NSMutableArray<TagLocationModel*>* locations;
我尝试使用适用于 iOS 的 JSONModel 框架从我的自定义对象中创建一个 JSON 文件。我得到错误:
EXCEPTION: Invalid type in JSON write (TagMediaModel)
当我调用 toJSONString 方法时,我遇到了这个问题。
[tagAutomaticModel toJSONString];
这是模型数据:
locations = (
"<TagLocationModel> \n [id]: 780307344\n [name]: Hotel Central Park, india\n</TagLocationModel>",
"<TagLocationModel> \n [id]: 463004401\n [name]: Miraj Cinema new year\n</TagLocationModel>",
"<TagLocationModel> \n [id]: 246187965\n [name]: Surya Treasure Island asia\n</TagLocationModel>",
);
"tag_posts" = (
"<TagMediaModel> \n [media_code]: BS0tQeFhU_Z\n [media_id]: 1492016420475981785\n [media_url]: https://scontent.cdninstagram.com/t51.2885-15/e15/17881459_...\n [media_type]: I\n</TagMediaModel>"
);
【问题讨论】:
-
您能分享一下您存储在其中的数据类型吗?
-
@Nirmalsinh 立即查看。我已经编辑了。
标签: ios objective-c json jsonmodel