带NSKIT字典编号NSArray的RestKit post
我正在使用RestKit将对象发布到服务器。 该对象包含一个NSArray,在将其添加到参数列表(NSDictionary)之前,我将其转换为NSDictionary NSDictionary queryParams如下所示(使用NSLog打印出来,为了清晰起见删除了一些字段) requestParams={带NSKIT字典编号NSArray的RestKit post,post,nsarray,nsdictionary,restkit,restkit-0.20,Post,Nsarray,Nsdictionary,Restkit,Restkit 0.20,我正在使用RestKit将对象发布到服务器。 该对象包含一个NSArray,在将其添加到参数列表(NSDictionary)之前,我将其转换为NSDictionary NSDictionary queryParams如下所示(使用NSLog打印出来,为了清晰起见删除了一些字段) requestParams={ "app_version" = "v1.0(1.006)"; "extended_information" = { "travel_locations" =
"app_version" = "v1.0(1.006)";
"extended_information" = {
"travel_locations" = (
{
"Aircard_or_Tablet" = 0;
Country = "United States";
"End_Date" = "04/12/2013";
"Start_Date" = "03/12/2013";
}
);
"using_voice" = 0;
};
}
然后我将其发送:
[objectManager postObject:nil path:server_path parameters:requestParams success:… failure:…]
问题在于,当RestKit创建查询字符串时,它似乎增加了字典中每个键的计数器,而不是数组中每个项的计数器。以下是服务器接收到的内容。为了清晰起见,我在每个参数后添加了一个换行符:
app_version=v1.0(1.006)
&extended_information[travel_locations][0][Aircard_or_Tablet]=0
&extended_information[travel_locations][1][Country]=United States
&extended_information[travel_locations][2][End_Date]=04/12/2013
&extended_information[travel_locations][3][Start_Date]=03/12/2013
&extended_information[using_data]=0
服务器希望(我也希望)该对象中的所有密钥的移动位置保持在[0],如下所示:
app_version=v1.0(1.006)
&extended_information[travel_locations][0][Aircard_or_Tablet]=0
&extended_information[travel_locations][0][Country]=United States
&extended_information[travel_locations][0][End_Date]=04/12/2013
&extended_information[travel_locations][0][Start_Date]=03/12/2013
&extended_information[using_data]=0
当然,如果第二个旅行地点在那里,它会有[1],第三个会有[2],依此类推
这是RestKit中的错误吗?是否有更好的方式发送此请求,使其生效?我没有更改服务器的选项
问题是:
如何让RestKit正确转换NSDictionary中的参数,使其不会增加数组对象中每个键的数组索引标识符
谢谢,
-Nico为什么要使用RestKit进行此操作?RestKit使所有其他通信变得非常简单。只是这一个细节似乎是个问题。但好的一点是,我可以像在以前的版本中那样实现这个特定的调用(没有RestKit)。。。