title: Post a json using swift
body: <p>I want to post a json to the server. The json looks like this </p>
  
  <pre><code>{
     "user": {
         "email": "email",
         "password": "pass"
     }
  }
  </code></pre>
  
  <p>This is what I have got so far, it is not working. I have problem of how to create a json object and how to post it. Thank you in advance. </p>
  
  <pre><code>    let myUrl = NSURL(string:"https://dev.jaloo.us/api/sessions.json")
      let postString:NSString = "email=\(username)&amp;password =\(password)"
      let postData:NSData = postString.dataUsingEncoding(NSUTF8StringEncoding)!
      let request = NSMutableURLRequest (URL:myUrl!)
      request.HTTPMethod = "POST"
      request.HTTPBody = postData
      request.addValue("application/json", forHTTPHeaderField: "Content-Type")
      request.addValue("application/json", forHTTPHeaderField: "Accept")
      var urlData: NSData? = NSURLConnection.sendSynchronousRequest(request, returningResponse: &amp;response, error: &amp;responseError)
  </code></pre>