Fehler (Error Domain=NSCocoaErrorDomain Code=3840 "Ungültiger Wert Zeichen 0." UserInfo={NSDebugDescription=Ungültiger Wert Zeichen 0.}

Ich bin immer diese Fehler als JSON-Ergebnis.Fehler. Während mein JSON ist eine gültige, überprüfen Sie es auf JSON vaildator online.

Dies ist mein code für JSON-Anfrage.

Alamofire.request(.POST, url, parameters: parameters, encoding:.JSON)
                .responseJSON { (request, response, result) in
                    hud.hide(true)
                    //Set flag to disale poor internet connection alert
                    weakInternet = false
                    print(result.error)
                    if (result.value != nil) {
                        print("API Response: \(result.value!)")
                        //Pass the response JSON to the completion block
                        completion(json: result.value!)
                    } else {
                        //Response JSON is NULL
                    }
            }

Wenn ich drücken Sie die gleiche Dienstleistung mit bestimmten request-Parameter, erhalte ich diese Antwort.

{"error":"success","post_data":{"first_name":"hd","last_name":"df","email":"[email protected]","password":"himanshu","confirm_password":"himanshu","companies":["Big Rattle Technologies_Fg_yes"],"institutes":[""]},"msg":"success","data":{"_id":"5742ae1564b35e37369f0838","first_name":"hd","last_name":"df","email":"[email protected]","profile_pic":"","loc":[0,0],"locs":{"type":"Point","coordinates":[0,0]},"institutes":[],"companies":[{"comapny_id":"555b2d0a678e79ed510041ce","group_id":"556c2434678e79a1820041dd","name":"Big Rattle Technologies","designation":"Fg","is_current":"yes"}],"device_token":"","user_group":"site_user","is_verified":0,"is_disclose":1,"is_discover":1,"wallNotification":1,"messageNotification":1,"matchNotification":1,"verificationSent":0,"status":1,"mobile":"","linkedin_id":"","facebook_id":"","os":"","qblox_id":12957726,"updated_at":"2016-05-23 07:15:33","created_at":"2016-05-23 07:15:33","current_company":"Big Rattle Technologies"}}

Jemand weiß, was das problem in meinem Fall?

  • Versuchen Sie, die .responseString { response in print("Response String: \(response.result.value)") } statt responseJSON zu sehen, was das Ergebnis aussieht.
  • Invalid value around character 0 Ihre Antwort ist nicht gültiges JSON.
  • Aber, ich habe in der postman-Antwort-service auf online-json-viewer und zeigt, dass die Antwort gültig ist ein.
  • Mir auch, habe den gleichen Fehler, weil meine Antwort nicht in gültiges JSON-Format. Es ist DOCTYPE ist html.
InformationsquelleAutor Himanshu | 2016-05-23
Schreibe einen Kommentar