POST array of objects in Alamofire POST method - Swift/IOS
<p>I'm trying to use Alamofire to post an array of multiple objects, which look like this:</p>

<pre><code>class Person {

dynamic var firstName: String?
dynamic var lastName: String?
dynamic var email: String?
dynamic var state: String?

init(){}
init(firstName:String, lastName:String, email:String){
    self.firstName = firstName
    self.lastName = lastName
    self.email = email
} }
</code></pre>

<p>I have created an array of Persons and added it to the dictionary like this:</p>

<pre><code>let zipCode = “20876”
    let city = “Rockville”
    let persons = [Person]()
    let state = “MD”

    let params: [String:AnyObject] = [
        “zipCode” : zipCode!,
        “city” : city!,
        “persons”: NSArray(array: persons),
        “state” : state!

    ]
</code></pre>

<p>And then tried to send it to a web service and I am getting an error message saying: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write’</p>

<pre><code>Alamofire.request(.POST, url, parameters: params, encoding: .JSON)
        .responseJSON {(req, res, json, error) in }
</code></pre>

<p>Did anyone try posting an array, is alamofire capable of doing so? 
I hope i made question clear. Sorry if this is too simple of a question to answer, i spent my whole day figuring this out, but didn't work out. 
Thank you</p>