-1
在我的Xcode项目不正确的JSON对象我送使用JSON数据POST请求使用Unirest库我的API:NSJSONSerialization问题。发送到API
NSDictionary *jsonObj = @{@"access_token": accessToken};
UNIHTTPJsonResponse* response = [[UNIRest postEntity:^(UNIBodyRequest* request) {
[request setUrl:@"http://localhost:9000/auth/facebook/token"];
[request setHeaders:headers];
// Converting NSDictionary to JSON:
[request setBody:[NSJSONSerialization dataWithJSONObject:jsonObj options:0 error:nil]];
}] asJson];
检查时jsonObj格式正确无误。
但在服务器端,我看到了这个对象:
{
'{"access_token":"12345678910"}': ''
}
当它应该是:
{
"access_token":"12345678910"
}
这到底是怎么回事?
显然,您正在发送JSON字符串作为JSON“对象”中的键。我对UNIRest不熟悉,但我怀疑它正在做第二个JSON序列化。 – 2014-11-05 12:36:41