java - JSONModel Generic Class -
i'm trying include jsonmodel project i'm working on... in project need data web service, returns me same data structure, different entries... build base jsonmodel class should work responses. looks this:
@interface webserviceresponse : jsonmodel @property (assign, nonatomic) bool success; @property (assign, nonatomic) int code; @property (strong, nonatomic) nsstring *message; @property (strong, nonatomic) nsstring *timestamp; @property (strong, nonatomic) nsarray *list; @end
the data web service given in "list" , dictionary (but differs different api methods call). except on error "null"...
how can define list property parse given dictionaries? given structure object null :(
thanks help, urkman
try using bwjsonmatcher, declare base response data model follows:
@interface webserviceresponse : nsobject<bwjsonvalueobject> @property (assign, nonatomic) bool success; @property (assign, nonatomic) int code; @property (strong, nonatomic) nsstring *message; @property (strong, nonatomic) nsstring *timestamp; @property (strong, nonatomic) nsarray *list; @end
for each of api, declare response model inherited webserviceresponse , override function typeinproperty: in protocol bwjsonvalueobject :
// apidatamodel corresponding data model in "list" of api - (class)typeinproperty:(nsstring *)property { if ([property isequaltostring:@"list"]) { return [apidatamodel class]; } return nil; }
further detailed examples of how use bwjsonmatcher can found here.
Comments
Post a Comment