如何从http响应中获取JSON

时间:2016-06-12 12:37:32

标签: ios objective-c afnetworking

这是问题,

我正在尝试使用AFNetworking发出POST请求,如下所示

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager setResponseSerializer:[AFCompoundResponseSerializer serializer]];

[manager POST:ZipPackersLoginURL parameters:@{@"Token" : @"myToken"} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

    //success block
    NSString *responseString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];

    completionBool = TRUE;

} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

    //failure block
    completionBool = TRUE;

}];

return completionBool;

我从网络服务获得此回复

UPDATE `users` SET FBID = 'xxx', email = 'xxx@hotmail.com',  FirstName = 'xxx',
MiddleName = NULL, LastName = 'xxx', FullName = 'xxx xxx', PictureUrl = 'https://xxx.xxx',
LocationID = xxx, LocationCity = 'xxx', LocationCountry = 'xxx', ProfileLink = 'xxx',
LastActive = NOW(), LastLoginIP = 'xxx'  WHERE FBID = 'xxx'{"status":200,"data":
{"AccessKey":"xxx","FBID":"xxx","Points":"0","FullName":"xxx xxx",
"FirstName":"xxx","PictureURL":"xxx","Country":"xxx","City":"xxx","CityID":"xxx",
"FriendsCount":0,"Friends":null}}

你可以看到它从某种查询开始,然后它包含我想要的JSON结构。

如何仅从上面的响应中获取JSON?

在postman中,如果我以漂亮模式查看响应,它只显示JSON,但在原始模式下,它会显示上面的响应。

非常感谢任何帮助!

0 个答案:

没有答案