我有一个从 REST Web 服务请求返回的 JSON 字符串,我想将此字符串解析为来自确定类的对象数组,这是 JSON 字符串
[
{
"validationCode": null,
"FirstName": "Samer",
"LastName": "Shame",
"MobileNumber": "0991992993",
"SimNumber": null,
"Email": null,
"PhoneNumber": "0991992994",
"Name": "Abo Alshamat",
"ID": 1
},
{
"validationCode": null,
"FirstName": "Ahmad",
"LastName": "Ali",
"MobileNumber": "0992993994",
"SimNumber": null,
"Email": null,
"PhoneNumber": "0992993995",
"Name": "AL-Kamal",
"ID": 2
},
{
"validationCode": null,
"FirstName": null,
"LastName": null,
"MobileNumber": "0993377800",
"SimNumber": null,
"Email": null,
"PhoneNumber": null,
"Name": "Abo-MAhmoud",
"ID": 12
},
{
"validationCode": null,
"FirstName": "William",
"LastName": "Ammar",
"MobileNumber": "0993994995",
"SimNumber": null,
"Email": null,
"PhoneNumber": "0993994996",
"Name": "Four Season",
"ID": 3
},
{
"validationCode": null,
"FirstName": "Ammar",
"LastName": "William",
"MobileNumber": "0999555777",
"SimNumber": null,
"Email": null,
"PhoneNumber": null,
"Name": "uuuuu",
"ID": 20
},
{
"validationCode": null,
"FirstName": null,
"LastName": null,
"MobileNumber": "0999888777",
"SimNumber": null,
"Email": null,
"PhoneNumber": null,
"Name": "NewOneFromI2",
"ID": 18
},
{
"validationCode": null,
"FirstName": null,
"LastName": null,
"MobileNumber": "0999998997",
"SimNumber": null,
"Email": null,
"PhoneNumber": "0999999998",
"Name": "JOURY",
"ID": 4
},
{
"validationCode": null,
"FirstName": null,
"LastName": null,
"MobileNumber": "202020",
"SimNumber": null,
"Email": null,
"PhoneNumber": null,
"Name": "TestTestRestaurant,Ammar,Hamed",
"ID": 19
}
]
我想从中获取实例的类是:
@interface Restaurant : NSObject
@property (nonatomic,strong) NSString *ID;
@property (nonatomic,strong) NSString* FirstName;
@property (nonatomic,strong) NSString* LastName;
@property (nonatomic,strong) NSString* MobileNumber;
@property (nonatomic,strong) NSString* simNumber;
@property (nonatomic,strong) NSString* PhoneNumber;
@property (nonatomic,strong) NSString* Name;
@end
最好的方法是什么,对不起,问题可能来自基本知识,但我对目标 C 很陌生
感谢您的时间。