gpt4 book ai didi

ios - 解析 JSON "Unescaped control character around character 981"时出错

转载 作者:搜寻专家 更新时间:2023-10-31 21:59:40 29 4
gpt4 key购买 nike

Error Domain=NSCocoaErrorDomain Code=3840 "Unescaped control character
around character 981." UserInfo={NSDebugDescription=Unescaped control
character around character 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 响应。

我在 Postman 中得到的响应:

{
"orderdetails": {
"status_code": "200",
"status_message": "Order details",
"billingandshipping": {
"billing": {
"firstname": "first",
"lastname": "last",
"email": "aa@bbb.com",
"address": "dasdesfrew",
"city": "Rajkot",
"area": "University Road",
"pincode": "360003",
"phone": "1234567890",
"mobileno": "1234567891"
},
"shipping": {
"firstname": "first",
"lastname": "last",
"email": "aa@bbb.com",
"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.."
}
]
}
}

最佳答案

据您所知,存在与“\n”相关的问题。

所以我建议您可以添加适合您的“”,如下所示:

"\n"=> "\\n"

因为这是一个叫做退格符的特殊字符。

关于ios - 解析 JSON "Unescaped control character around character 981"时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39247981/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com