用
HashMap<String ,String> params=new HashMap<String, String>(7);
for(int i=1;i<=7;i++)
{
params.put("params_"+i, arr[i]);
}
在CustomJobjectRequest
类,因为你目前正在使用String
类型为在地图值CustomJobjectRequest
类,但发送String[]
时创建的对象类型CustomJobjectRequest
的类。
要将单个参数中的所有值发送到服务器,请使用。JSONObject
使用所有键值创建json对象,如下所示:
JSONObject jsonObject=new JSONObject();
for(int i=1;i<=7;i++)
{
arr[i]="questionId_"+i+"_"+"ans_"+i;
jsonObject.put("params_"+i,arr[i]);
}
HashMap<String ,String> params=new HashMap<String, String>();
params.put("params",jsonObject.toString());
要在服务器端发送所有值,params
并转换为JSON对象并进行迭代以获取所有值