MAP数组

Map[] maps=new Map[len];
JSONArray jsonArray=new JSONArray();
for(int i=0;i<len;i++){
maps[i]= new HashMap();
JSONObject jsonObject=new JSONObject();
if(taskIds[i]!=null || taskIds[i]!=""){
maps[i].put("userId", userId);
maps[i].put("Task_ID", taskIds[i]);
int node_id=Integer.parseInt(NodeIds[i]);
maps[i].put("Node_ID", node_id);
maps[i].put("taskName", taskNames[i]);
maps[i].put("operationID", operationID);
maps[i].put("refreshUrl", refreshUrl);
   maps[i].put("openTabId", openTabIds[i]);
   maps[i].put("opinion", opinion);
   jsonObject.put("taskId",  taskIds[i]);
   jsonObject.put("nodeId",  node_id);
   jsonArray.put(i,jsonObject);
}

}

在以上代码中需要使用MAP数组,而改数组的每一项也是一个map。之前的操作是在for循环中每次定义一个map,然后将他put到MAP数组中,后来证实这种做法不可取。最后该改进为上面的写法,之前想MAP[i]中去put所需要的数据。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值