3
注意:我需要使用ObjectMapper,而不是AlamoFireObjectMapper。通過ObjectMapper映射Alamofire responseJSON
您如何映射而不使用JSON,而是從responseJSON數據映射到用戶?以下是試圖從responseJSON到jsonn,然後再回到數據(是用戶)。我猜這肯定有辦法嗎?
還是應該使用AlamoFire的responseData?
public class User: Mappable {
var username: String?
required public init?(map: Map) {
}
// Mappable
public func mapping(map: Map) {
username <- map["username"]
}
}
Alamofire.request(
url,
method: .get,
headers: headers_employees).responseJSON {
response in
// Map via ObjectMapper
let [User] = Mapper<User>().map(JSONString: JSONString)
}