I got a json objects which starts with an array of objects. I wanna use JSONModel together with this json object but I can't find an example how to do this.
Here's my json:
{
"days": [{
"date": "2016-12-22T00:00:00.000Z",
"items": [{ ... }]
},{
"date": ...
}
}
I created a DaysModel
@interface DaysModel : JSONModel
@property (nonatomic) NSArray<DayModel *> *days;
And the corresponding DayModel (in fact, I only need an Array of "DayModel Types")
@interface DaysModel : JSONModel
@property (nonatomic) NSDate *date;
@property (nonatomic) NSArray<ItemModel *> *items;
But when initializing my Model with a string
DaysModel *myDays = [[DaysModel alloc] initWithString:teststring error:&jsonError];
The content of myDays.days will be an Array of Dictionaries instead of an Array of DayModels.
Probably you forgot to add the protocol, try to read the documentation on github?
https://github.com/jsonmodel/jsonmodel#model-collections
try to add
in
DaysModel
and change from:
to: