Judging by the examples attached to the JSONModel library, you can try to implement your own methods to establish the values of the properties of the model. As far as I know, it’s impossible to combine all possible values of the names field of various types in one property, so you have to create 3 separate properties that can be combined into a separate class. It may look like this:
@interface Names : NSObject @property (nonatomic, retain) NSString* names_string; @property (nonatomic, retain) NSNumber* names_bool; @property (nonatomic, retain) NSArray* names_array; @end
Suppose your model class looks like this:
@interface MyModel : JSONModel @property (nonatomic) Names* names; @end
Add an implementation of the following methods:
@implementation Names @end @implementation MyModel - (void)setNamesWithNSString:(NSString *)string { self.names = [[Names alloc] init]; self.names.names_string = string; } - (void)setNamesWithNSArray:(NSArray *)array { self.names = [[Names alloc] init]; self.names.names_array = array; } - (void)setNamesWithNSNumber:(NSNumber *)boolValue { self.names = [[Names alloc] init]; self.names.names_bool = boolValue; } @end
Now, after creating an object of your model, check which of the properties (names_bool, names_array or names_string) was initialized.