【发布时间】:2015-11-18 18:44:04
【问题描述】:
我想通过使用 volley 库将具有以下格式的 jsonobject 发送到服务器 { “用户 ID”:12, “答案”:{ “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();
}
如果我想使用 StringRequest 我应该如何使用 POST 方法将此 JsonObject 发送到服务器
【问题讨论】:
标签: post android-volley jsonobject