I need to map the following Json with AlamofireObjectMapper:
{
"user": {
"id": 2,
"first_name": "Dealer",
"last_name": "Seller",
"email": "seller@winfooz.com",
"authentication_token": "L6HzhZWdWhtxNwVkrsjY",
"documents_uploaded": false,
"type": "Dealer"
}
}
I wrote the following part of code, but the mapped object return nil!
class SystemUser:Mappable{
func mapping(map: Map) {
type <- map[SystemUserIdentifiers.UserType] //"type"
firstName <- map[SystemUserIdentifiers.FirstName]
lastName <- map[SystemUserIdentifiers.LastName]
internalIdentifier <- map[SystemUserIdentifiers.InternalIdentifier]
email <- map[SystemUserIdentifiers.Email]
documentsUploaded <- map[SystemUserIdentifiers.DocumentsUploaded]
authenticationToken <- map[SystemUserIdentifiers.AuthenticationToken]
}
}
Here is sending the post request:
Alamofire.request(.POST, URL, parameters: parameters, encoding: .JSON).responseObject {
(response: Response<SystemUser, NSError>) in
guard let user = response.result.value else{
return
}
print(user.authenticationToken)
}
What is the correct way to map rooted Json?