从 alamofire 获取数据(responseString)
get Data from alamofire (responseString)
我正在使用此代码检索数据
Alamofire.request(urlString, method: .post, parameters: parameters,encoding: JSONEncoding.default, headers: headers)
.responseString() { response in
switch response.result {
case .success(let data):
let jsonData = JSON(data)
print(jsonData)
case .failure(let error):
print("\(error) - hello world")
}
}
服务器发送的结果是
{"result":"Opertion is successfull"}
但我只想要值部分 "Opertion is successfull"
使用 alamofire 中的代码 documentation
Alamofire.request(urlString, method: .post, parameters: parameters,encoding: JSONEncoding.default, headers: headers)
.responseString() { response in
if let jsonData = response.result.value {
print("JSON: \(jsonData)") // serialized json response
}
}
我正在使用此代码检索数据
Alamofire.request(urlString, method: .post, parameters: parameters,encoding: JSONEncoding.default, headers: headers)
.responseString() { response in
switch response.result {
case .success(let data):
let jsonData = JSON(data)
print(jsonData)
case .failure(let error):
print("\(error) - hello world")
}
}
服务器发送的结果是
{"result":"Opertion is successfull"}
但我只想要值部分 "Opertion is successfull"
使用 alamofire 中的代码 documentation
Alamofire.request(urlString, method: .post, parameters: parameters,encoding: JSONEncoding.default, headers: headers)
.responseString() { response in
if let jsonData = response.result.value {
print("JSON: \(jsonData)") // serialized json response
}
}