我的服务器发送一个包含十进制值的JSON。但是Alamofire却改为使用String:
服务器发送的JSON:
{
quantity = 10;
inProgress = 0;
lastUpdatedAt = "2018-07-21 12:01:26";
pending = 10;
alreadySent = 438.11;
total = 448.11;
}
与Alamofire通话:
Alamofire.request(URLRequest)
.validate()
.responseJSON { response in
debugPrint(response)
switch response.result {
case .success(let value):
sink.send(value: value)
sink.sendCompleted()
case .failure(let error):
sink.send(error: NetworkError(error: error as NSError))
}
响应是以下JSON:
{
quantity = 10;
inProgress = 0;
lastUpdatedAt = "2018-07-21 12:01:26";
pending = 10;
alreadySent = "438.11";
total = "448.11";
}
已经发送和总计现在是字符串而不是数字。