I'm trying to find a way to properly map a collection of objects to a JSON dictionary with a specific format.
I have an object with the following interface (partial):
@interface Reward : NSObject
...
@property (nonatomic, copy) NSString* title;
@property (nonatomic, copy) NSString* comment;
@property (nonatomic, strong) NSMutableOrderedSet* receivers; //set of User
...
@end
And the User object (partial) is:
@interface User : NSManagedObject
...
@property (nonatomic, strong) NSNumber* userId
...
@end
The goal is to POST a Reward object, along with the receivers property.
I could come up with an RKObjectMapping that works for title and comment attributes, but the receivers collection requires the following format:
"receivers":{"0":"<user_id_of_first_user>", "1":"<user_id_of_second_user>", ...}
My main problem is how to insert the index as a key.
I could do it manually and tweak the NSURLRequest HTTPBody, but I was hoping to find a more clean/RestKit way.
Thanks in advance.