@@ -251,8 +251,16 @@ -(id)initWithDictionary:(NSDictionary*)dict error:(NSError**)err
251251
252252 if (property) {
253253
254+ // 0.0) handle structs
255+ if (property.structName ) {
256+ NSLog (@" struct found: %@ " , property.structName );
257+
258+ // continue to next property
259+ // continue;
260+ }
261+
254262 // 0) handle primitives
255- if (property.type == nil ) {
263+ if (property.type == nil && property. structName == nil ) {
256264
257265 // just copy the value
258266 [self setValue: jsonValue forKey: property.name];
@@ -326,7 +334,9 @@ -(id)initWithDictionary:(NSDictionary*)dict error:(NSError**)err
326334 // JMLog(@"to type: [%@] from type: [%@] transformer: [%@]", p.type, sourceClass, selectorName);
327335
328336 // build a method selector for the property and json object classes
329- NSString * selectorName = [NSString stringWithFormat: @" %@ From%@ :" , property.type, sourceClass];
337+ NSString * selectorName = [NSString stringWithFormat: @" %@ From%@ :" ,
338+ (property.structName? property.structName : property.type), // target name
339+ sourceClass]; // source name
330340 SEL selector = NSSelectorFromString (selectorName);
331341
332342 // check if there's a transformer with that name
@@ -468,7 +478,18 @@ -(void)__restrospectProperties
468478 [scanner scanString: @" >" intoString: NULL ];
469479 }
470480
471- } else {
481+ }
482+ // check if the property is a structure
483+ else if ([scanner scanString: @" {" intoString: &propertyType]) {
484+ [scanner scanCharactersFromSet: [NSCharacterSet alphanumericCharacterSet ]
485+ intoString: &propertyType];
486+
487+ p.isStandardJSONType = NO ;
488+ p.structName = propertyType;
489+
490+ }
491+ // the property must be a primitive
492+ else {
472493
473494 // the property contains a primitive data type
474495 [scanner scanUpToCharactersFromSet: [NSCharacterSet characterSetWithCharactersInString: @" ," ]
@@ -664,7 +685,7 @@ -(NSDictionary*)toDictionary
664685 }
665686
666687 // 2) check for standard types OR 2.1) primitives
667- if (p.isStandardJSONType || p.type ==nil ) {
688+ if (p.structName == nil && (p. isStandardJSONType || p.type ==nil ) ) {
668689 [tempDictionary setValue: value forKeyPath: keyPath];
669690 continue ;
670691 }
@@ -673,7 +694,7 @@ -(NSDictionary*)toDictionary
673694 if (YES ) {
674695
675696 // create selector from the property's class name
676- NSString * selectorName = [NSString stringWithFormat: @" %@ From%@ :" , @" JSONObject" , p.type];
697+ NSString * selectorName = [NSString stringWithFormat: @" %@ From%@ :" , @" JSONObject" , p.type?p. type: p.structName ];
677698 SEL selector = NSSelectorFromString (selectorName);
678699
679700 // check if there's a transformer declared
0 commit comments