Closed sssuourabh closed 9 years ago
automatic array mapping happens when dictionary key is the same as property name and the class name, so you could do 2 things:
1- Name the property apiServices
or apiService
where the dictionary key would be the same
OR
2- write mapping:
InCodeMappingProvider *mappingProvider = [[InCodeMappingProvider alloc] init];
[mappingProvider mapFromDictionaryKey:@"WHATEVER_THE_KEY_IS" toPropertyKey:@"Service" withObjectType:APIService.class forClass:APIOrganization.class];
// Add any other mapping needed
[[ObjectMapper sharedInstance] setMappingProvider:mappingProvider];
I have json which contains an array of other classes as well so how to do nested mapping between classes. Example @interface APIOrganization : NSObject
@property (nonatomic , strong) NSString id; @property (nonatomic , strong) NSString name; @property (nonatomic , strong) APIPhoto rmcPhoto; @property (nonatomic , strong) NSMutableArray Service; @property (nonatomic , strong) NSMutableArray *osd; @end
Here the APIOrganization class i am using
APIOrganization *ApiOrg = [[ObjectMapper sharedInstance] objectFromSource:orgDict toInstanceOfClass:[APIOrganization class]]; Service is array of class Service class but i am not getting the array which contain Service
Please guide me its very urgent @interface APIService : NSObject @property (nonatomic , strong) NSString *id;// Doubt
@property (nonatomic , strong) NSString *name;
@property (nonatomic , strong) NSString *descriptions;
@property (nonatomic , strong) NSString *updatedOn;