我有以下代码:
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对象(比如String),我有一个RKObjectMapping,其值应该发送给Rest Api。
可以将RKObjectMapping转换为JSON吗?