Tag: json

字符981附近的非转义控制字符。parsingJSON时发生错误

错误域= NSCocoaErrorDomain代码= 3840“字符981周围的未转义的控制字符。 UserInfo = {NSDebugDescription =字符981周围的非转义控制字符。} 我在请求的回应中遇到了以上错误。 以下是代码行: Alamofire.request(.POST, urlStr, parameters: parameter, encoding: .JSON, headers: nil).validate().responseJSON { response in switch response.result { case .Success(let JSON): completionHandler(JSON as! NSDictionary) case.Failure(let Error): print(Error) } } 它在Postman中给出了JSON响应。 我在邮递员那里得到的回应是: { "orderdetails": { "status_code": "200", "status_message": "Order details", "billingandshipping": { "billing": { "firstname": "first", "lastname": "last", "email": "aa@bbb.com", "address": […]

在目标c中从NSMutableArray中获取错误的ID

我是iOS新手,当我search后在我的文本框中添加search框给我错误的ID。 在我的代码中有三个数组,一个是id,另一个是名字,第三个是search。 我的代码: – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sections{ if(tableView == table) { if(isFilter) { return [searchArray count]; } else return [idarray count]; } } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if(tableView == table) { if(isFilter) { cell.textLabel.text=[NSString stringWithFormat:@"%@",[searchArray objectAtIndex:indexPath.row]]; } else { cell.textLabel.text=[NSString stringWithFormat:@"%@",[namearray objectAtIndex:indexPath.row]]; } } } – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if(tableView […]

如何使用Swifty Json将POST请求中的JSON数据保存到字典中?

我能够在控制台中打印JSON数据,看起来像这样 { "created_at" : "2016-07-21 20:46:53", "name" : "PB Admin", "id" : 1, "updated_at" : "2016-07-21 12:46:53", "lname" : "Admin", "access_lvl" : 1, "email" : "admin@admin.com", "fname" : "PB" } ,但无法将其保存到字典中。 POST请求的方法 private func makeHTTPPostRequest(path: String, body: NSDictionary) { let request = NSMutableURLRequest(URL: NSURL(string: path)!) // Set the method to POST request.addValue("application/json", forHTTPHeaderField: "Content-Type") request.addValue("application/json", […]

Visual Studio Cordova,通过远程代理问题构buildiOS包

我们一直在使用Cordova平台在Visual Studid Community 2015中构build移动应用程序,旨在发布到Android和iOS。 Android我们没有任何问题,但想提交给苹果的应用程序。 问题是我们过去几天试图设置一个远程代理,但是却遇到了一堵砖墙。 在我们的Macbook Pro上,我们安装了最新版本的节点,因为我们正在运行Cordova CLI 5.4.1。 我们也安装了xCode最新版本。 注册参加苹果的开发者计划,创build一个分发configuration文件,获得我们的证书等。换句话说,我们已经勾选了所有的框。 现在的问题是,我们尝试运行远程代理,并试图通过Visual Studio远程连接到我们的Mac提交给苹果商店。 如果我们使用远程代理,我们会在Macterminal上看到以下404错误: GET /certs/{pin number} 200 12ms – 3.49kb GET /modules/taco-remote 404 3ms 在Visual Studio中,popup如下窗口: Unable to connect to remote iOS build server. Underlying exception: The remote server returned an error: (404) not found. 如果我们尝试使用remotebuild,则会出现错误“JSON remotebuild.configparsing错误”。 我们已经尝试过find这些文档或信息,但是所有的东西都只是指向: http : //taco.visualstudio.com/en-us/docs/ios-guide/用于远程构build或Visual Studio的关于如何安装的页面并运行远程代理。 我们已经按照这些步骤10次,但只是继续得到相同的错误。 […]

如何使用Swift 3和Alamofire从JSON下载图像?

如何使用Alamofire和Swift 3从JSON下载图像? 我正在获取数据字典。 看到下面的JSON响应。 我能够在标签中打印数据,但是我无法下载图像。 这是我从API获得的回应。 userJson userJson userJson userJson [“status”:1,“student”:{“admission_date”=“14/06/2017”; “admission_no”= 13538; “class_teacher”=“Caroline Forbes”; dob = “2001年4月5日”; 电子邮件=“ranisagar.sivadas@gmail.com”; “father_name”=“SAGAR SIVADAS”; 性别=男性; image = “/system/images/86/j1f9DiJi_medium.jpg?1504593436”; “mother_name”=“RANI RS”; name =“Abhijith Sagar”; 电话= 9066260799; 宗教=印度教; “school_email”=“13538.861@demo.in”; “student_id”= 86; }, “消息”:细节获取成功。] 这是我的代码。 func SetUpUIProfiledata() { APIManager.sharedInstance.getParentDataFromURL(){(userJson)-> Void in let swiftyJsonVar = JSON(userJson) print("userJson userJson userJson userJson",userJson) print("swiftyJsonVar",swiftyJsonVar) let […]

JSON序列化错误

我从一个生成json数组的php脚本中提取数据。 iOS更新后,我的jsonserialization崩溃的应用程序。 json应该根据jsonformatter.org和freeformatter.com/json-validator.html(符合RFC4627)进行良好的组织。 这是代码。 任何帮助是极大的赞赏! func parseJSON() { var jsonResult: NSMutableArray = NSMutableArray() do{ jsonResult = try JSONSerialization.jsonObject(with: self.data as Data, options:JSONSerialization.ReadingOptions.allowFragments) as! NSMutableArray } catch let error as NSError { print(error) } var jsonElement: NSDictionary = NSDictionary() let locations: NSMutableArray = NSMutableArray() for i in 0 ..< jsonResult.count { jsonElement = jsonResult[i] as! NSDictionary […]

使用NIB定义从故事板出来的UITableViewCell

我使用Json数组来显示来自服务器的数据。 当我将CellIdentifier更改为我在CellIdentifier中使用的@Cell时,pushDetailView正在工作,它将进入下一页,但是当我再次更改为CustomCell时,只需在第一页中显示城市和州的名称,而当我点击时不会去下一页。 我需要@CustomCell的原因是因为在第一页需要2个标签视图,当我将其更改为@cell时,它只显示一个标签。 谢谢。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"CustomCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } // Configure the cell… City * cityObject; cityObject = [ citiesArry objectAtIndex:indexPath.row]; cell.textLabel.text = cityObject.cityState; cell.detailTextLabel.text = cityObject.cityPopulation; cell.detailTextLabel.numberOfLines = 4; //NSData *imageData = […]

我如何得到在iOS应用程序中的Node.js服务器的响应?

我有一个Node.js服务器,当用户login时,发送JWT(JSON Web Token)作为响应。如何在我的Swift 4 iOS应用程序中获得响应? func handleLogin() { guard let username = usernameTextField.text, let password = passwordTextField.text else { print("Invalid form") return } guard let url = URL(string: "http://localhost:3000/users/authenticate") else { return } var request = URLRequest(url: url) request.httpMethod = "POST" request.addValue("application/json", forHTTPHeaderField: "Content-Type") let authUser = Login(username: username, password: password) do { let jsonBody […]

在IOS中parsing嵌套的JSON代码

我试图parsingiOS中的以下JSON代码。 JSON代码由一组编号为0到x的游戏组成。 我一直在四处search,但似乎无法find任何具有这种格式的JSON的例子。 { "command":"show_my_games", "0":{"gameid":"7","foruserid":"16","againstuserid":"0","casefor":"","caseagainst":"","status":"0","argumentid":"7","againstusername":null,"forusername":"Gem","argument":"argument 1"}, "1":{"gameid":"8","foruserid":"15","againstuserid":"16","casefor":"","caseagainst":"","status":"0","argumentid":"23","againstusername":"Gem","forusername":"Nick","argument":"argument 2"}, "2":{"gameid":"9","foruserid":"18","againstuserid":"16","casefor":"","caseagainst":"","status":"0","argumentid":"26","againstusername":"Gem","forusername":"Nick","argument":"argument 3"} } 我创build了一个游戏对象,对于JSON数组中的每个项目,我想创build一个新的游戏对象,并将其添加到游戏数组中。 我无法parsingJSON,我很感激任何帮助或build议。 我正在尝试使用的代码是 NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&err]; for (NSMutableDictionary * gameItem in json) { Game *obj = [Game new]; obj.GameID=[gameItem objectForKey:@"gameid"]; obj.Argument=[gameItem objectForKey:@"argument"]; obj.CaseFor=[gameItem objectForKey:@"casefor"]; obj.CaseAgainst=[gameItem objectForKey:@"caseagainst"]; obj.CaseForOwner=[gameItem objectForKey:@"forusername"]; obj.CaseAgainstOwner=[gameItem objectForKey:@"againstusername"]; obj.CaseForOwnerID=[gameItem objectForKey:@"foruserid"]; obj.CaseAgainstOwnerID=[gameItem objectForKey:@"againstuserid"]; //add to the players game […]

JSON POST在iOs中不起作用

我试图使用JSON POST方法发布一些数据到Web服务,我已经尝试了很多方法来做到这一点,但没有任何工作。 这是我的代码,请检查: NSArray *objects=[NSArray arrayWithObjects:@"value1", @"value2",@"value3", @"value4",@"value5", @"value6",@"value7", @"value8",@"value9", nil] ; NSArray *keys=[NSArray arrayWithObjects:@"FirstName", @"LastName",@"UserName", @"Password",@"Email", @"Gender",@"DeviceId", @"DeviceName",@"ProfileImage", nil]; NSData *_jsonData=nil; NSString *_jsonString=nil; NSURL *url=[NSURL URLWithString:urlstring]; NSDictionary *JsonDictionary=[NSDictionary dictionaryWithObjects:objects forKeys:keys]; if([NSJSONSerialization isValidJSONObject:JsonDictionary]){ _jsonData=[NSJSONSerialization dataWithJSONObject:JsonDictionary options:0 error:nil]; _jsonString=[[NSString alloc]initWithData:_jsonData encoding:NSUTF8StringEncoding]; } NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; // [request setHTTPBody:_jsonData]; // [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; // [request […]