美文网首页
JSONModel 使用记录

JSONModel 使用记录

作者: NapoleonY | 来源:发表于2021-05-19 19:19 被阅读0次
  1. JSONModel 嵌套解析
    JSONModel 解析 json 数据时,如果 json 内部有嵌套,如果想要解析则需要声明一个 Model 同名的 protocol 。举例如下:
@interface SuccItem : JSONModel
@property (nonatomic, strong) NSArray<ReplayModel> *datasetList;
@end

@protocol ReplayModel;

@interface ReplayModel : JSONModel
@property (nonatomic, assign) NSInteger taskId;
@property (nonatomic, strong) NSString *taskName;
@end

SuccItem 内部包含一个数组 datasetList,datasetList 是一个 ReplayModel 数组,如果要准确解析 datasetList,需要声明一个 ReplayModel 同名的 protocol,即 @protocol ReplayModel;,同时 SuccItem 中对应的数组要声明好 @property (nonatomic, strong) NSArray<ReplayModel> *datasetList;

相关文章

网友评论

      本文标题:JSONModel 使用记录

      本文链接:https://www.haomeiwen.com/subject/akapjltx.html