title: Alamofire garbage at end error while parsing json
body: <p>I'm connecting to my server on localhost to fetch some data. The data returned to this request is a JSON, on <strong>Postman</strong> the JSON is correctly shown, but when I'm playing with iOS, Alamofire returns me an error: <br></p>
  
  <blockquote>
    <p>responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error
    Domain=NSCocoaErrorDomain Code=3840 "Garbage at end."
    UserInfo={NSDebugDescription=Garbage at end.}))</p>
  </blockquote>
  
  <p><br> 
  The JSON in question is:</p>
  
  <pre><code>{
    "name": "TestName",
    "surname": "TestSurname"
  }
  </code></pre>
  
  <p>The thing that I do not understand is that if I force my server to return the json in form of a string so something like </p>
  
  <pre><code>"{"name": "TestName after update","surname": "TestSurname"}"
  </code></pre>
  
  <p>Alamofire does not complain and parses it correctly. How is that? I thought that specifying the parameter <code>responseJSON</code> it would have worked the other way around.</p>
  
  <pre><code>Alamofire.request("http://192.168.1.4:8080/user/abcdf").validate().responseJSON { response in
              switch response.result {
              case .success:
                  // DO stuff
  
              case .failure(let error):
                  print(error)
              }
          }
  </code></pre>