I want to send a jsonobject with below format to server by using volley library { "user_id": 12, "answers": { "11": 3, "12": 4, "13": 5 } }
JSONObject object = new JSONObject();
try {
object.put("user_id", user_id);
JSONObject answers = new JSONObject();
for (int i = 0; i < questions.size(); i++) {
JSONObject answer = new JSONObject();
answer.put(questions.get(i).getId(),questions.get(i).getAnswer());
answers.put("answers", answer);
object.put("answers", answer);
}
} catch (JSONException e) {
e.printStackTrace();
}
If I want to use StringRequest how should I send this JsonObject to server by using POST method