Suppose that I have a User object:
class User: Mappable {
var username: String?
var age: Int?
var weight: Double!
var array: [Any]?
var dictionary: [String : Any] = [:]
var bestFriend: User? // Nested User object
var friends: [User]? // Array of Users
var birthday: Date?
required init?(map: Map) {
}
// Mappable
func mapping(map: Map) {
username <- map["username"]
age <- map["age"]
weight <- map["weight"]
array <- map["arr"]
dictionary <- map["dict"]
bestFriend <- map["best_friend"]
friends <- map["friends"]
birthday <- (map["birthday"], DateTransform())
}
}
And my Json contains an array of that object: [User] How can I map this array even if it has not a specific field name? This is what I did:
class Users: Mappable {
var users: [User]?
required init?(map: Map) {
}
// Mappable
func mapping(map: Map) {
//What have I to put here??
}
}