how to make httpPost call with json encoded body?

I was making a common mistake sequence of json object was wrong. For example, I was sending it like first_name, email, etc. where as the correct sequence was email, first_name.

My code:

boolean result = false;
HttpClient hc = new DefaultHttpClient();
String message;

HttpPost p = new HttpPost(url);
JSONObject object = new JSONObject();
try {
    object.put("updates", updates);
    object.put("mobile", mobile);
    object.put("last_name", lastname);
    object.put("first_name", firstname);
    object.put("email", email);

} catch (Exception ex) {

}

try {
    message = object.toString();

    p.setEntity(new StringEntity(message, "UTF8"));
    p.setHeader("Content-type", "application/json");
    HttpResponse resp = hc.execute(p);
    if (resp != null) {
        if (resp.getStatusLine().getStatusCode() == 204)
            result = true;
    }

    Log.d("Status line", "" + resp.getStatusLine().getStatusCode());
} catch (Exception e) {
    e.printStackTrace();

}

return result;