RESTful サービスへの POST は成功しましたが、次の 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:@""];
//このコード行なしで値を指定して試してみましたが、変更はありません!
サーバーを変更できるとは思わないので、これを回避する方法を誰か教えてもらえますか?
ありがとう