I need to send a JSON request to a REST service. I’m using Restkit RKParams to send a request.
Currently it works as follows:
[params setValue:@"-46.566393" forParam:@"checkin[lng]"];
[params setValue:@"-23.541576" forParam:@"checkin[lat]"];
Send:
{
"checkin":
{
"lng":"-26.566393",
"lat":"-63.541576"
}
}
Now I want to form JSON data like this (with few more items):
{
"checkin":
{
"lng":"-26.566393",
"lat":"-63.541576",
"votes":
[
{"vote_id":28},
{"vote_id":11}
]
}
}
How would I set the params to work as desired? It is possible to do this?
RestKit does handle nested models, but it looks like it doesn’t do that directly in RKParams. I would look at some of the other classes to do what you’re trying to do. Key-value mapping looks like it will do what you want.
Or if you want to hack it,
might just work. No promises, though.