Created
September 13, 2011 23:02
-
-
Save shyam-habarakada/1215427 to your computer and use it in GitHub Desktop.
rest-kit-mapping-options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* RestKit QUESTION | |
* | |
* What is the correct way to map the following server response variants, and | |
* is there a preferred option? | |
* | |
* Also, keeping in mind that these responses can represent nested objects that need to | |
* be mapped to corresponding object hierarchies on the client side. I can give more | |
* examples of that if needed. | |
* | |
* Finally, the client side is core-data, so the mappings are managed object mappings. | |
* | |
*/ | |
// format #1 | |
// named array of objects | |
// This is the format shown on the RestKit wiki examples | |
{ | |
persons: [ | |
{ | |
id: 1, | |
last_name: "Johnson", | |
first_name: "Stephanie", | |
gender: "female" | |
}, | |
{ | |
id: 2, | |
last_name: "Black", | |
first_name: "Joe", | |
gender: "male" | |
} | |
] | |
} | |
// format #2 | |
// naked array of named objects | |
[ | |
{ | |
person: { | |
id: 1, | |
last_name: "Johnson", | |
first_name: "Stephanie", | |
gender: "female" | |
} | |
}, | |
{ | |
person: { | |
id: 2, | |
last_name: "Black", | |
first_name: "Joe", | |
gender: "male" | |
} | |
} | |
] | |
// format #3 | |
// naked array of (unnamed) objects | |
[ | |
{ | |
id: 1, | |
last_name: "Johnson", | |
first_name: "Stephanie", | |
gender: "female" | |
}, | |
{ | |
id: 2, | |
last_name: "Black", | |
first_name: "Joe", | |
gender: "male", | |
} | |
] | |
// format #4 | |
// named array of named objects | |
{ | |
persons: [ | |
{ | |
person: { | |
id: 1, | |
last_name: "Johnson", | |
first_name: "Stephanie", | |
gender: "female" | |
} | |
}, | |
{ | |
person: { | |
id: 2, | |
last_name: "Black", | |
first_name: "Joe", | |
gender: "male" | |
} | |
} | |
] | |
} |
grgcombs
commented
Sep 15, 2011
via email
Until we come up with a system of automatic mapping, this is probably as good as we'll get, barring some convenience methods later on
Sent from my iPhone.
…On Sep 15, 2011, at 3:50 PM, ***@***.*** wrote:
Greg, that would definitely work. I am still learning the intricacies of KVC, so not sure if that's the correct way ...
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1215427
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment