原始响应数据
{
"data":{
"assign":[
],
"unassign":[
{
"menuInfoId":1703730557314928,
"op":{
"id":1703730558166896,
"cid":1000,
"isHidden":false,
"menuinfoName":"SPC.menuName.randon1596788981007",
"iconCls":"cui-btn-add",
"sort":3,
"target":"SELF",
"defaultOperate":false,
"rolePermission":{
"roleId":3,
"menuOperateId":1703730558166896
},
"layNo":2,
"nameDisplay":"新增"
},
"nameDisplay":"测试方案"
},
{
"menuInfoId":1703730557314928,
"op":{
"id":1703730558003056,
"cid":1000,
"isHidden":false,
"menuinfoName":"SPC.menuName.randon1596788981007",
"iconCls":"cui-btn-del",
"sort":3,
"target":"SELF",
"defaultOperate":false,
"rolePermission":{
"roleId":3,
"menuOperateId":1703730558003056
},
"layNo":2,
"nameDisplay":"删除"
},
"nameDisplay":"测试方案"
},
{
"menuInfoId":1703730557314928,
"op":{
"id":1703730557708144,
"cid":1000,
"isHidden":false,
"menuinfoId":1703730557314928,
"menuinfoName":"SPC.menuName.randon1596788981007",
"iconCls":"cui-btn-modify",
"sort":3,
"target":"SELF",
"defaultOperate":false,
"rolePermission":{
"roleId":3,
"menuOperateId":1703730557708144
},
"layNo":2,
"nameDisplay":"测试"
},
"nameDisplay":"测试方案"
}
]
}
}
import org.json.JSONArray;
import org.json.JSONObject;
List list1 = new ArrayList();
String jsonStr = prev.getResponseDataAsString();
JSONObject jsonobj = new JSONObject(jsonStr);
JSONArray result = jsonobj.getJSONObject("data").getJSONArray("unassign");
for (int i = 0; i < result.length(); i++) {
long id = result.getJSONObject(i).getJSONObject("op").getLong("id");
String tipname = result.getJSONObject(i).getString("nameDisplay");
String names =result.getJSONObject(i).getJSONObject("op").getString("nameDisplay");
if(!(names.equals("-"))){
tipname +=names;
}
nameid =tipname+":"+id.toString();
Value.add(nameid+"\r\n");
}
vars.putObject("list1",Value);
|