convert json string to objective-c model for MJExtenstion
Replace strJSON with your json string . After running project, you can see .h and .m file content in the log window.
1. json string is{
"weather": [
{
"names": "china",
"data": [
"2℃",
"-2℃",
"1℃",
"11℃",
"-1℃",
"1℃"
],
"times": [
10,
11,
12,
13,
14,
15
]
},
{
"names": "america",
"data": [
"2℃",
"-12℃",
"11℃",
"0℃",
"-1℃",
"1℃"
],
"times": [
10,
11,
12,
13,
14,
15
]
}
]
}
- After Running the project, you cat get .h file is
@interface WeatherModelWeather : NSObject
@property (copy, nonatomic) NSString *names;
@property (strong, nonatomic) NSArray *data;
@property (strong, nonatomic) NSArray *times;
@end
@interface WeatherModel : NSObject
@property (strong, nonatomic) NSArray *weather;
@end
.m file is
#import "WeatherModel.h"
@implementation WeatherModelWeather : NSObject
+ (NSDictionary *)objectClassInArray
{
return @{
};
}
@end
@implementation WeatherModel : NSObject
+ (NSDictionary *)objectClassInArray
{
return @{
@"weather":@"WeatherModelWeather"
};
}
@end