php - "nn" added before JSONObject -


in application, i'm sending http request json login details mysql database.

just i've been trying database , php api run utf-8 encoding.

however, when try login now, error:

07-18 14:06:41.507: e/json(32162): nn{"tag":"login1","success":1,"error":0,"user":{"id":"1","email":"admin@fleetcoordinator.se","fullname":"administrator","password":"admin","userrole":"admin","username":"admin"}}n  07-18 14:06:41.512: e/json parser(32162): error parsing data org.json.jsonexception: value nn of type java.lang.string cannot converted jsonobject 

obivously it's "nn" before json-data crashing application, come from?

php api:

// response array $response = array("tag" => $tag, "success" => 0, "error" => 0);       else if ($tag == "login1"){      //request type login1, fltcoor db     $username = $_post['username'];     $password = $_post['password'];      //check user, fill user array     $user = $db1->getlogindetails($username, $password);     if($user != false){         //user found         //put user details json response array         $response["success"] = 1;         $response["user"]["id"]         = $user["id"];         $response["user"]["email"]      = $user["email"];         $response["user"]["fullname"]   = $user["fullname"];         $response["user"]["password"]   = $user["password"];         $response["user"]["userrole"]   = $user["userrole"];         $response["user"]["username"]   = $user["username"];         //echo json response         echo json_encode($response);     } else {         //user not found, echo json error = 1(user not found)         $response["error"] = 1;         $response["error_msg"] = "wrong username or password";         echo json_encode($response);     }        

can see these "nn" coming from. please tell me if need more information track problem.

this problem caused missin "\" in stringbuilder.

        try {         bufferedreader reader = new bufferedreader(new inputstreamreader(                 is, "utf-8"), 8);         stringbuilder sb = new stringbuilder();         string line = null;         while ((line = reader.readline()) != null) {             sb.append(line + "\n");          sb.append(line + "\n"); sb.append(line + "n");, \ missing , adding 2 "nn" before jsonobject. 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -