我很难用ObjectMapper将json映射到对象数组。这是我的模型对象。
class Participant : Mappable {
var user_global_id: String!
var user_app_id: String!
init(){
}
required init?(_ map: Map) {
}
// Mappable
func mapping(map: Map) {
user_global_id <- map["user_global_id"]
user_app_id <- map["user_app_id"]
}
}我的json看起来:"[{\"user_global_id\":5093363330056192,\"user_app_id\":11}]"
我打电话给ObjectMapper:
let participants = Mapper<[Participant]>().map(json["registeredParticipants"])上线给出错误:Type '[Participant]' does not conform to protocol 'Mappable'
发布于 2016-06-16 10:39:29
主要错误是将数组作为泛型属性传递。这是解决办法
Mapper<Participant>().mapArray(json["registeredParticipants"])https://stackoverflow.com/questions/37856312
复制相似问题