Closed Adrift001 closed 5 years ago
{ "approvers": [ [ { "userId": 3, "userName": "Joe", "headUrl": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1560678148301&di=7b48c9d15211af372146cca167898046&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20171030%2F26ed195281334ba4b1752394b60eb29a.jpeg" }, { "userId": 4, "userName": "Manolo", "headUrl": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1560678148300&di=4396ce27dfcc3818018f011356ba7881&imgtype=0&src=http%3A%2F%2Fm.360buyimg.com%2Fpop%2Fjfs%2Ft23434%2F230%2F1763906670%2F10667%2F55866a07%2F5b697898N78cd1466.jpg" }, null ], [ { "userId": 4, "userName": "Manolo", "headUrl": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1560678148300&di=4396ce27dfcc3818018f011356ba7881&imgtype=0&src=http%3A%2F%2Fm.360buyimg.com%2Fpop%2Fjfs%2Ft23434%2F230%2F1763906670%2F10667%2F55866a07%2F5b697898N78cd1466.jpg" }, null, { "userId": 11, "userName": "啊啊啊啊", "headUrl": "" } ] ] }
class LeaveApproverModel: Mappable { var userId: Double = 0 var userName = "" var headUrl = "" required init?(map: Map) { } func mapping(map: Map) { userId <- map["userId"] userName <- map["userName"] headUrl <- map["headUrl"] } } class LeaveApproversModel: Mappable { var approvers: [[LeaveApproverModel]] = [[]] required init?(map: Map) { } func mapping(map: Map) { approvers <- map["approvers"] } }
let repo = Mapper<LeaveApproversModel>().map(myJSONDictionary)
I exepected something like:
{"approvers":[[LeaveApproversModel, LeaveApproversModel], [LeaveApproversModel, LeaveApproversModel]]}
{"approvers":[[]]}
reference #152
Your JSON dictionary:
Your model:
What you did:
What you expected:
I exepected something like:
What you got: