I'm trying to wrap my HTTP POST request with a key. In other words, I want to turn this:
{
"category_id"=>"1",
"food_name_token"=>"Pizza",
"id"=>"1"
}
into this:
{
"dish" =>
{
"category_id"=>"1",
"food_name_token"=>"Pizza",
"id"=>"1"
}
}
I tried using the 'rootKeyPath' method in RestKit:
serializationMapping.rootKeyPath = @"dish";
But that gave me this weirdly formatted string :
{
"dish"=>
"{
\n \"category_id\" = 1;
\n \"food_name_token\" = Pizza;
\n id = 1;
\n}
"}
It uses equal signs and semicolons instead of arrows and commas, and adds in all these linebreaks and escape backslashes.
Any idea why? And any suggestions on what I can do instead?
P.S. I'm using a Rails backend
I found out with Restkit I can wrap attributes using brackets:
[dishMapping mayKeyPath:@"dish[food_name_token]" toAttribute:@"placeToken"];
And this gives me a normal output without the weird formatting.