title: How to detect when Alamofire request is null?
body: <p>I am using <code>Alamofire</code> to do my requests of my API on my <code>Swift</code> application and it works well but I also want to detect when the JSON response is equals to <code>null</code>.</p>
  
  <p>I have tried comparing the response to <code>nil</code> and <code>NSNull</code> but none of those worked for me. I also have tried using <code>JSON.empty</code> but it also does not seem to work. Further, I have created a <code>default</code> option on my <code>switch</code> application trying to catch the options that are not <code>success</code> or <code>failure</code>.</p>
  
  <p>Actually I have only maintained the <code>JSON.empty</code> option but it never enters on else statement. </p>
  
  <p>This is the code that I have right now:</p>
  
  <pre><code>Alamofire.request(encodedUrl!, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: nil).responseJSON { response in
  
     switch(response.result) {
         case .success(_):
            if let JSON = response.result.value as? [[String : AnyObject]]{
                if JSON.isEmpty == false{
                    //Here the code if the request returns data
                }else{
                    //Here I wanted to use the code if null is retrieved
                }
            }else{
                //The JSON cannot be converted
            }
            break
  
         case .failure(_):
            //Failure 
            break
     } 
  }
  </code></pre>
  
  <p>How can I handle <code>null</code> responses on <code>Alamofire</code>?</p>
  
  <p>Thanks in advance!</p>