-1

我有对象

@interface Hourly (CoreDataProperties)

@property (nullable, nonatomic, retain) NSDate *dt;
@property (nullable, nonatomic, retain) NSNumber *temp;
@property (nullable, nonatomic, retain) NSNumber *temp_min;
@property (nullable, nonatomic, retain) NSNumber *temp_max;
@property (nullable, nonatomic, retain) NSNumber *humidity;
@property (nullable, nonatomic, retain) NSNumber *pressure;
@property (nullable, nonatomic, retain) NSString *main;
@property (nullable, nonatomic, retain) NSString *des;
@property (nullable, nonatomic, retain) NSString *icon;

@end

和网址

http://api.openweathermap.org/data/2.5/forecast/dayly?lat=35&lon=139&cnt=2

我不能通过 jsonmodel pod 将 json 添加到对象,因为列表中的天气是一个数组。

4

2 回答 2

0

@Ngọc Thái:我不太明白你的问题。但是,如果您想从 JSON(包含对象数组)解析为对象。

很简单,你可以试试:https ://github.com/elado/jastor#arrays

希望这有帮助!

于 2015-09-30T16:58:25.183 回答
0

试试我的项目BWJSONMatcher。它可以帮助您轻松地将 json 字符串转换为 NSArray:

NSArray *dataArray = [BWJSONMatcher matchJSON:YOURJSONSTRING withClass:[Hourly class]];

该库是完全开源的,并在 MIT 许可下。

于 2015-11-10T08:51:25.933 回答