国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > iOS > 正文

IOS用AFN發(fā)送字符串形式的Json數(shù)據(jù)給服務(wù)器實例

2020-07-26 02:50:56
字體:
供稿:網(wǎng)友

每個人遇到后臺的需求不一樣,我只能寫出自己目前遇到的需求和做法,我的后臺是需要一個Json的key,對應(yīng)一個字符串類型的字典,后臺要求的是帶雙引號和冒號的字典,所以就拼接了一下

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];  // 發(fā)送post請求//  manager.responseSerializer = [AFJSONResponseSerializer serializer];  manager.responseSerializer = [AFJSONResponseSerializer serializer];  manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];  //  manager.requestSerializer=[AFHTTPRequestSerializer serializer];  NSDictionary *json = [NSDictionary dictionary];   NSString *str = [NSString stringWithFormat:@"{/"city/":/"%@/",/"country/":/"%@/",/"headimgurl/":/"%@/",/"language/":/"%@/",/"openid/":/"%@/",/"province/":/"%@/",/"sex/":%@,/"unionid/":/"%@/",/"userName/":/"%@/"}",self.userInfoDict[@"city"],self.userInfoDict[@"country"],self.userInfoDict[@"headimgurl"],self.userInfoDict[@"language"],self.userInfoDict[@"openid"],self.userInfoDict[@"province"],self.userInfoDict[@"sex"],self.userInfoDict[@"unionid"],self.userInfoDict[@"nickname"]];  json = @{//      @"city":self.userInfoDict[@"city"],//      @"country":self.userInfoDict[@"country"],//      @"headimgurl":self.userInfoDict[@"headimgurl"],//      @"language":self.userInfoDict[@"language"],//      @"openid":self.userInfoDict[@"openid"],//      @"province":self.userInfoDict[@"province"],//      @"sex":self.userInfoDict[@"sex"],//      @"unionid":self.userInfoDict[@"unionid"],//      @"userName":self.userInfoDict[@"nickname"],      @"json":str,//      @"json":@"json"                };  NSLog(@"post調(diào)試%@",json);  NSString *URLStr = @"http://10.62.16.247:8080/LoginServlet.bmh";    [manager POST:URLStr parameters:json progress:^(NSProgress * _Nonnull uploadProgress) {      } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {    NSString *str = responseObject;    NSLog(@"post回調(diào)====%@",str);    NSLog(@"post成功");  } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {    NSLog(@"post失敗");  }];

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 宁河县| 葫芦岛市| 尼玛县| 花莲市| 阜宁县| 三台县| 微博| 肥乡县| 运城市| 遵义县| 祁门县| 密山市| 南召县| 东兴市| 田阳县| 梧州市| 原阳县| 都江堰市| 岳阳县| 故城县| 乌拉特后旗| 星座| 六盘水市| 巴东县| 科技| 江山市| 绩溪县| 芮城县| 宁城县| 凤山县| 桂平市| 绿春县| 保德县| 河南省| 独山县| 竹溪县| 临城县| 台东市| 渭南市| 宁武县| 班玛县|