title: RX Alamofire Swift empty response JSON
body: <p>I am using Alamofire with rx and i'm having one issue that if the call is a success (status 200) there is no JSON returned. This triggers my error code. If I get status 400 I get JSON so the call is fine.</p>
  
  <p>How do I specify that the response is JSON, but not to error if empty and status code 200?</p>
  
  <p>Thanks!</p>
  
  <pre><code>func createUser(httpBody: AccountDetails!) -&gt; Observable&lt;(NSHTTPURLResponse, AnyObject)&gt; {
  
      return Alamofire.Manager.rx_request(.POST,
          APIService.REGISTER_ENDPOINT,
          parameters: httpBody.getParameters(),
          encoding: .JSON,
          headers: nil)
          .flatMap {
              $0
                  .validate(statusCode: 200..&lt;501)
                  .validate(contentType: ["application/json"])
                  .rx_responseJSON()
              .map { (response:NSHTTPURLResponse, object:AnyObject) -&gt; (NSHTTPURLResponse, AnyObject) in
                      return (response, object)
              }
      }
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I fixed this by changing .rx_responseJSON() to .rx_responseData() and returning NSData instead of AnyObject as the second parameter. Now the call succeeds and I manually convert the data to JSON. Not sure if this is the correct solution but it will suffice for now. Happy to hear better solutions though.
  Thanks</p>