2

我正在开发一个 ios 应用程序,但是当我尝试使用以下方法获取服务器响应时:

 if let jsonResult = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? NSDictionary

我从服务器收到一条错误消息:

无法读取数据,因为它的格式不正确。

因为我的服务器有问题的代码行:

{"tripReport":[{"duration":-,"distance":0.0,"reportText1":" " ,"reportText2":"-" ,"totalDistance":0.0,"message1":" ","message2":" ","dateTime2":" ","dateTime1":" "}],"size":0}

我想在此行之前获得服务器响应,例如:{"movementReport":[{"message":"7.88 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","reportText":"POSITION","speed":53.0,"dateTime":"2016-Jan-20 11:36 AM","route":null,"longitude":73.270053,"latitude":31.37281}
通过使用 split func 或其他任何东西..我可以将我的响应分成两个字符串吗?

4

0 回答 0