【发布时间】:2018-02-16 07:34:22
【问题描述】:
在Android 上使用Volley 发送特定的json 请求时遇到问题。
我正在使用以下内容发送简单的 json 请求:
final JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("userId", "testUserId");
jsonObject.put("password", "testPass");
} catch (JSONException e) {
Log.d("JSONexception","JSON EXCEPITON: "+e.tostring());
}
但是对于更复杂的请求,我不确定如何创建 json 正文请求。这是我要创建的 json 请求的示例:
{
“userId” : “testUserId”,
“password” : “testPass”,
“validParameters” : [
{
“key” : “testKey”,
“value” : “testValue”
}
],
“requestTimestamp” : null
}
【问题讨论】:
-
你需要学习一些 JSON 基础知识......你需要添加名为“validParameters”的 JSONArray,然后使用“key”和“value”属性将新的 JSONObject 添加到这个数组中......
标签: android json request android-volley