Question: I have to post some data on the server. JSON structure of the data is given below.

```
"hospital": {
    "hospitalId": "1212111",
    "hospitalName": "xcxcxcx",
    "address": {
        "addressLine1": "fagsgsah",
        "locality": {
            "id": "",
            "name": "",
            "pLink": ""
        },
        "city": {
            "id": "",
            "name": "",
            "pLink": ""
        }           
    }
}

```

I can easily using Dictionary to achieve this data structure. But I have read that creating Model is the best practice for posting and parsing the data. I have created four models `Hospital`, `Address`, `State`,`City` for more flexibility. There could be more properties in any Models, as you can see in the Hospital model. My question is how the given JSON structure would be achieved, which I can pass as parameters to the Alamofire. Should I have to `write multiple initializer` in models as per the data requirement? 

```
import UIKit

class Hospital {
    var hospitalId:String?
    var hospitalName:String?
    var address:Address?
    var fee:Int?
    var openingTime:UInt64?
    var closingTime:UInt64?
}

/** Address **/
class Address {
    var addressLine1:String?
    var locality:Locality?
    var city:City?
}

/** City **/
class City {
    var cityId:String?
    var cityName:String?
    var cityPLink:String?
}

/** locality **/
class Locality {
    var localityId:String?
    var localityName:String?
    var localityPLink:String?
}

```

Answer: 
Almofire doesn't support this automatic binding of Modal classes into the Response. Yes, you should write the Modal Initializers with the JSON data for each modal class. 

<https://gist.github.com/jpotts18/e39ee74de84ae094b270> provides the example of how the Simple JSON, Collections and Nested JSON data can be bind to modal class.
I'm not yet tried out swift4 Codable which could be option for you if you use swift4, if it is swift 3 then I would recommend to use [AlamofireObjectMapper](https://github.com/tristanhimmelman/AlamofireObjectMapper) 

Please have a look into examples it is really easy to use.