Try something like that:
JSONObject jsonParams = new JSONObject();
try {
JSONObject jsComm = new JSONObject();
JSONObject jsLoc = new JSONObject();
jsLoc.put("lat", (float) lat);
jsLoc.put("long", (float) lng);
jsComm.put("location", jsLoc);
jsComm.put("text", txt);
jsonParams.put("comment", jsComm);
} catch (JSONException e2) {
Log.d("exception", "Exception while parsing json array :" + e2.toString());
e2.printStackTrace();
}
then use :
AbstractHttpEntity entity = null;
entity = new ByteArrayEntity(jsonParams.toString().getBytes("UTF8"));
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(entity);