111minutes/BWObjectMapping — pull request #1 by lucasmedeirosleite (2013-02-19 21:16:04+00:00)
Title: Adding support for mapping child attribute to a parent attribute

If you have a class like this:

```objective-c

@interface Person : NSObject

@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *email;
@property (nonatomic, copy) NSString *skype;

@end

```

And a JSON like this:

```JSON

{
"person": {
"name": "Lucas",
"email": "lucastoc@gmail.com",
"contact": {
"skype": "aspmedeiros"
}
}
}

```

You can map it like this

```objective-c

[BWObjectMapping mappingForObject:[Person class] block:^(BWObjectMapping *mapping) {
[mapping mapKeyPath:@"name" toAttribute:@"name"];
[mapping mapKeyPath:@"email" toAttribute:@"email"];
[mapping mapKeyPath:@"contact.skype" toAttribute:@"skype"];
[[BWObjectMapper shared] registerMapping:mapping withRootKeyPath:@"person"];
}];

```