我成功地 POST 到一个 RESTful 服务,但它正在发回以下 json 响应;
T restkit.network:RKObjectLoader.m:202 bodyAsString: {"Successful":true,"Message":"We have received 9138 message(s)","Data":null}
(来自 RestKit 调试器/记录器)。如您所见,该 JSON 中没有根密钥。现在 RestKit 在尝试使用以下代码映射它时会抱怨;
RKObjectMapping *serverResponseMapping = [RKObjectMapping mappingForClass:[ServerReply class]];
[serverResponseMapping setRootKeyPath:@""]; //tried without this and with a value but no change!
[serverResponseMapping mapKeyPath:@"Success" toAttribute:@"success"];
[serverResponseMapping mapKeyPath:@"Message" toAttribute:@"message"];
[serverResponseMapping mapKeyPath:@"Data" toAttribute:@"data"];
[[manager mappingProvider] addObjectMapping:serverResponseMapping];
尝试映射时,我从 Restkit 收到以下错误;
W restkit.object_mapping:RKObjectMapper.m:87 Adding mapping error: Could not find an object mapping for keyPath: ''
只是为了突出
-[serverResponseMapping setRootKeyPath:@""];
//尝试没有这行代码,也有一个值但没有变化!
谁能告诉我如何解决这个问题,因为我认为我无法更改服务器?
谢谢