ios - RestKit and Restlet JSON key-value -


in restkit mapping class json key-value use,

rkobjectmapping * usermapping = [rkobjectmapping mappingforclass:[user class]];         [usermapping mapkeypath:@"primarykey" toattribute:@"id"]; [[rkobjectmanager sharedmanager].mappingprovider setmapping:useremapping forkeypath:@"clientuser"]; 

however in android, if restlet used, have add @jsonproperty("primarykey"), when declaring variable in class. , key value mapping done.

is there simpler way ios restkit similar android restlet?

thanks in advance.

you can in ios

rkobjectmapping* articlemapping = [rkobjectmapping mappingforclass:[article class]]; [articlemapping addattributemappingsfromdictionary:@{          @"title": @"title",         @"body": @"body",         @"author": @"author",         @"publication_date": @"publicationdate"     }]; 

and

// create our new author mapping rkobjectmapping* authormapping = [rkobjectmapping mappingforclass:[author class] ]; // note: when source , destination key paths symmetrical, can use addattributesfromarray: shortcut instead of addattributesfromdictionary: [authormapping addattributemappingsfromarray:@[ @"name", @"email" ]]; 

refer here


Comments