Ausgabe
Error Domain=NSCocoaErrorDomain Code=3840 “Steuerzeichen ohne Escapezeichen
um Zeichen 981 herum.” UserInfo={NSDebugDescription=Nicht maskiertes Steuerzeichen
um Zeichen 981.}
Ich erhalte den obigen Fehler als Antwort auf eine Anfrage.
Unten sind die Codezeilen:
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)
}
}
Es gibt eine JSON-Antwort in Postman .
Die Antwort, die ich in Postman bekomme:
{
"orderdetails": {
"status_code": "200",
"status_message": "Order details",
"billingandshipping": {
"billing": {
"firstname": "first",
"lastname": "last",
"email": "[email protected]",
"address": "dasdesfrew",
"city": "Rajkot",
"area": "University Road",
"pincode": "360003",
"phone": "1234567890",
"mobileno": "1234567891"
},
"shipping": {
"firstname": "first",
"lastname": "last",
"email": "[email protected]",
"address": "dasdesfrew",
"city": "dasdesfrew",
"area": "dcdc",
"pincode": "360003",
"phone": "1234567890",
"mobileno": "1234567891"
}
},
"orders": [
{
"order_id": "77",
"order_date": "09-08-2016 13:05:29",
"delivery_date": "10-08-2016",
"order_items": [
{
"Sr": "1",
"product_name": "Lemon",
"gujtitle": "લીંબુ ",
"product_code": "000057",
"product_price": "108.00",
"product_qty": "2",
"unit": "1 kg.",
"product_total": "216"
}
],
"final_total": "216.00",
"shipping_cost": "0.00",
"order_total": "216.00",
"discount_type": "null",
"discount_amount": "null",
"coupon_name": "null",
"comment": "gdhdj\nfghd.g\nghj\n\n\n\n\n\n\n\n\n\n.."
}
]
}
}
Lösung
Wie Ihnen gesagt wurde, gibt es ein Problem im Zusammenhang mit “\n”.
Ich schlage also vor, dass Sie “” hinzufügen können, was für Sie funktioniert, wie unten:
“\n”=> “\\n”
Weil dies ein Sonderzeichen ist, das als Backspace-Zeichen bezeichnet wird.
Beantwortet von – Ashish Gondaliya
Antwort geprüft von – Dawn Plyler (FixError Volunteer)