取object对像中的数据

取object对像中的数据

若Object是List集合

List resultList = mdmWritebackDao.getEsolutionCallData(esolutionCall, indexOf, pageSize);for (Object obj : resultList) {

Object[] objs = (Object[]) obj;

String param1 = (String) objs[0];

String param2 = (String) objs[1];

String param3 = (String) objs[2];

}

若Object数据是数组形式的,eg:

[{id=f25738c6547688470154cd6bc2d50002, title=1000日儿科幻灯片}, {id=f25738c6547688470154cd6bc2d50002, title=1000日儿科幻灯片}, {id=f25738c6547688470154cd6bc2d50002, title=1000日儿科幻灯片}]首先用JSONArray进行数据转换,结果

net.sf.json.JSONArray$JSONArrayListIterator@294398db

变成了数组对像,然后迭代每个数组元素,当迭代第一个数据时,eg

{id=f25738c6547688470154cd6bc2d50002, title=1000日儿科幻灯片}

再用JSONObject转换,最后获取数据。

完整代码如下:

Object object = param.get("dataList");

net.sf.json.JSONArray ja = net.sf.json.JSONArray.fromObject(object);

@SuppressWarnings("rawtypes")

Iterator iterator = ja.iterator();

while(iterator.hasNext()){

Object next = iterator.next();

JSONObject jaC = net.sf.json.JSONObject.fromObject(next);

String docId = (String) jaC.get("id");

String docTitle = (String) jaC.get("title");

}根据数据的样式选择合适的json转换形式。

相关数据

一起来看看我国军用的刺刀都有哪些
365体育欧洲版本

一起来看看我国军用的刺刀都有哪些

⌛ 07-16 👁️ 8025
qq怎么删除收藏的表情
365bet娱乐场游戏

qq怎么删除收藏的表情

⌛ 08-05 👁️ 8489