分析数据org.json.JSONException时出错:第0个字符处的输入结束


Error parsing data org.json.JSONException: End of input at character 0 of

这是我的java代码:类UpdateProfile扩展AsyncTask{

    /**
     * Before starting background thread Show Progress Dialog
     */
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        Log.d("UpdateProfile", "pre-execute");
    }
    /**
     * Creating product
     */
    protected String doInBackground(String... args) {
        String status = null;
        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("email", "kjljkl"));
        params.add(new BasicNameValuePair("imageuri","lkjlk" ));
        params.add(new BasicNameValuePair("username","klkjljl" ));
        params.add(new BasicNameValuePair("bio","lklklkl" ));
        // getting JSON Object
        // Note that create product url accepts POST method
        Log.d("UpdateProfile", "Before-HttpRequest");
        JSONObject json = jsonParser.makeHttpRequest(url_update_profile, "POST", params);
        // check log cat fro response
        Log.d("UpdateProfile", "After-HttpRequest");
        // check for success tag
        try {
            success = json.getInt("success");
            if (success == 1) {
                // successfully created product
                Log.d("UpdateProfile", "user profile updated");
                status = "success";
                // closing this screen
                // finish();
            } else {
                // failed to create product
                Log.d("UpdateProfile", "user profile not updated");
                status="fail";
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return status;
    }
    /**
     * After completing background task Dismiss the progress dialog
     * *
     */
    protected void onPostExecute(String status) {
        // dismiss the dialog once done
        if(status.equals("success"))
        {
            Log.d("UpdateProfile", "user profile updated");
            //Toast.makeText(getApplicationContext(), "Login success", Toast.LENGTH_LONG).show();
            //Intent intent = new Intent(getApplicationContext(), Comment.class);
            //startActivity(intent);
        }
        else
        {
            Log.d("UpdateProfile", "user profile not updated");
            //Toast.makeText(getApplicationContext(), "Login error", Toast.LENGTH_LONG).show();
        }
    }
}

这是我的Php代码:

<?php
if (isset($_POST['email'])&& isset($_POST['imageuri'])&& isset($_POST['username'])&& isset($_POST['bio'])){
 // In my previous post for question, i did not give the code as I thought it will not hit this if statement. But as it confused all, I am giving the code snippet here
 if($imageuri != null)
        {
            // Insert into Db
            $response["success"] = 1;
            $response["message"] = "UserProfile successfully  inserted in imageuri."; 
            echo json_encode($response);
        }
  // Do the same for other 2 params - username, bio, as well
}
?>

我的代码中出现了什么错误?分析数据org.json.JSONException时出错:第0个字符处的输入结束请帮帮我。

<?php
if (isset($_POST['email'])&& isset($_POST['imageuri'])&& isset($_POST['username'])&& isset($_POST['bio'])){
}

这是它命中的if语句,我假设HTTPPOST一切正常。然后它将不返回JSON,因此您的jsonParser将无法解析任何内容。请尝试在此处回显一些json。