尝试使用Alamofire和AlamofireObjectMapper时出现错误
我调用api的功能
static func getUberIntegration(completion: @escaping ([Integrations]?) -> ()) {
let url = "\(Url.baseURL())/integrations"
let headers = Headers.authorization()
Alamofire.request(url, headers: headers).responseArray { (response: DataResponse<[Integrations]>) in
let integration = response.result.value
print(integration!)
completion(integration)
}
}
模型
class Integrations: Object, Mappable {
@objc dynamic var id: Int32 = 0
@objc dynamic var type: String = ""
@objc dynamic var active: Bool = false
override static func primaryKey() -> String? {
return "id"
}
required convenience init?(map: Map) {
self.init()
}
func mapping(map: Map) {
id <- map["id"]
type <- map["type"]
active <- map["active"]
}
}
状态代码200
时来自API的响应 {
"id": 120,
"type": "Integration",
"active": true
}
任何人都可以解释为什么会出现这个问题?当我打印调试状态代码是返回代码200但无法读取json数据
我收到此错误
错误Domain = com.alamofireobjectmapper.error Code = 2“ObjectMapper 无法序列化回复。“