0
回到我使用Alamofire使請求的API休息和SwiftyJSON處理JSON響應,以下列方式:問題wtih網址JSON
Alamofire.request(.POST, urlTo, parameters: params, encoding: .URL).responseString(completionHandler: {
(request: NSURLRequest, response: NSHTTPURLResponse?,
responseBody: String?, error: NSError?) -> Void in
var response = self.stripHtmlTags(responseBody!)
// Parse the response to NSData
if let data = (response as NSString).dataUsingEncoding(NSUTF8StringEncoding) {
let json = JSON(data: data)
println(json)
}
})
但是我有一個問題與網址在JSON返回,返回按以下方式:
"url_image" : "path1\/path2\/path3\/path4\/path5\/p\/1342.jpg"
我可以格式化,但我想知道,如果這件事情與編碼傳遞給Alamofire或別的東西,我怎麼能解決這個問題。
任何幫助都非常感謝。
我知道我可以格式化它,請閱讀我的問題,但我想知道爲什麼會發生這種情況? –
@VictorSigler發生這種情況是因爲它們插入反斜槓來分隔可能不安全的字符。如果我有一個字符串,並且在字符串中有一個引號,我需要爲該字符分隔,比如「somestring \」something「。 – Schemetrical