JSON Invalid value around character 0 debugging
<p>how do I properly debug the error message</p>

<pre><code>Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}
</code></pre>

<p>I see this in different scenarios happening and I always struggle to find the real reason.
In the case above I have the following url I return a JSON response from:</p>

<pre><code>http://SERVERIP/v1/aeds&amp;latitude=48.1848308444472&amp;longitude=11.2527083605633
</code></pre>

<p><strong>Server Response via Postman</strong></p>

<pre><code>{
  "data": [
    {
      "deviceReference": "D200",
      "owner": "Owner 200",
      "latitude": "48.185240",
      "longitude": "11.258890",
      "street": "StreetName",
      "featureTypeId": "1"
    },
    {
      "deviceReference": "D300",
      "owner": "Owner 300",
      "latitude": "48.179290",
      "longitude": "11.253350",
      "street": "StreetName",
      "featureTypeId": "1"
    },
    {
      "deviceReference": "D100",
      "owner": "Owner 100",
      "latitude": "48.176226",
      "longitude": "11.238890",
      "street": "StreetName",
      "featureTypeId": "1"
    }
  ],
  "meta": {
    "Heading 1": "H1",
    "Heading 2": "H2"
  }
}
</code></pre>

<p>The json gets returned properly in my opinion, still I receive the message, when calling the URL via Alamofire and processing it.</p>

<pre><code>func getAEDInRange(latitude: Double, longitude: Double, completionHandler: (Result&lt;[AED], NSError&gt;) -&gt; Void) {
    Alamofire.request(Router.GetAEDInRange("?latitude=\(latitude)&amp;longitude=\(longitude)")).responseArray { (response: Response&lt;[AED], NSError&gt;) -&gt; Void in
        print(response.result)
    }
}
</code></pre>

<p><strong>responseArray Method</strong></p>

<pre><code>public func responseArray&lt;T: ResponseJSONObjectSerializable&gt;(completionHandler: Response&lt;[T], NSError&gt; -&gt; Void) -&gt; Self {
    let serializer = ResponseSerializer&lt;[T], NSError&gt; { request, response, data, error in

        guard error == nil else {
            return .Failure(error!)
        }

        guard let responseData = data else {
            let failureReason = "Array could not be serialized because input data was nil."
            let error = Error.errorWithCode(.DataSerializationFailed, failureReason: failureReason)
            return .Failure(error)
        }

        let JSONResponseSerializer = Request.JSONResponseSerializer(options: .AllowFragments)
        let result = JSONResponseSerializer.serializeResponse(request, response, responseData, error)

        switch result {

        case .Success(let value):
            let json = SwiftyJSON.JSON(value)

            // Get Data content of JSON
            let jsonData = json["data"]

            var objects: [T] = []
            for (_, item) in jsonData {
                if let object = T(json: item) {
                    objects.append(object)
                }
            }
            return .Success(objects)

        case .Failure(let error):
            return .Failure(error)
        }
    }
    return response(responseSerializer: serializer, completionHandler: completionHandler)
}
</code></pre>

<p>The literal URL in the browser returns:</p>

<pre><code>{"data":[{"deviceReference":"D200","owner":"Owner 200","latitude":"48.185240","longitude":"11.258890","street":"StreetName","featureTypeId":"1"},{"deviceReference":"D300","owner":"Owner 300","latitude":"48.179290","longitude":"11.253350","street":"StreetName","featureTypeId":"1"},{"deviceReference":"D100","owner":"Owner 100","latitude":"48.176226","longitude":"11.238890","street":"StreetName","featureTypeId":"1"}],"meta":{"Heading 1":"H1","Heading 2":"H2"}}
</code></pre>