我有以下代码:
NSString *url = @"http://mysite.com"
RKURL *baseURL = [RKURL URLWithBaseURLString:url];
objectManager = [RKObjectManager objectManagerWithBaseURL:baseURL];
objectManager.client.baseURL = baseURL;
objectManager.serializationMIMEType = RKMIMETypeJSON;
NSString *token = @"Token is getting from rest API"
[[objectManager client] setValue:token forHTTPHeaderField:@"token"];
RKClient *client= [objectManager client];
RKRequest * therequest = [client requestWithResourcePath:@"/create"];
[therequest setHTTPBodyString:@"{user:user}"]; //Here receive a JSON value
[therequest setMethod:RKRequestMethodPOST];
[therequest setDelegate:self];
[therequest send];
这段代码工作正常......但我有一个问题,我需要向 Rest API 发送一个 JSON 对象(如字符串),并且我有一个 RKObjectMapping,其中包含应该发送到 Rest Api 的值。
可以将 RKObjectMapping 转换为 JSON 吗?