當前位置:成語大全網 - 新華字典 - 如何把model轉化為json 簡書

如何把model轉化為json 簡書

基本使用

假設妳的 JSON 串像下面這樣子:

{

"id":"10",

"country":"Germany",

"dialCode": 49,

"isInEurope":true

}

創建壹個妳自己的類,並繼承至 JSONModel

在妳的頭文件裏面進行聲明妳所需要的 JSON key值

#import "JSONModel.h"

@interface CountryModel : JSONModel

@property (assign, nonatomic) int id;

@property (strong, nonatomic) NSString* countr