list對象轉json


for (LdInquiryPage ldInquiryPage : l) {
List<LdInquiryCostEntity> lson = jdbcTemplate.query(sqlson+ldInquiryPage.getId()+"'", rowMapperson);
ldInquiryPage.setLdInquiryCostList(lson);
ldInquiryPage.setInContent(sdf.format(ldInquiryPage.getCreateDate()));
}

 

1、LIST對象轉json字符串
net.sf.json.JSONArray jsonarray = net.sf.json.JSONArray.fromObject(l);
js.put("content", jsonarray.toString());

 

2、jsonArray取值

JSONArray json

for (int i = 0; i < json.size(); i++) {
JSONObject jsonObject=(JSONObject) json.get(i);

String sql = "UPDATE ld_inquiry SET updatestate='0' WHERE id='"+jsonObject.get("id")+"' AND updatestate='"+jsonObject.get("updatestate")+"'";
// String sql="update ldc_handbook_order set hbo_upstate='0' where hbo_orderno='"+jsonObject.get("ordercode")+"' and hbo_upstate='"+jsonObject.get("updatestate")+"'";
jdbcTemplate.update(sql);
}

 

3、json字符串轉list對象

List<CommonContractEntity> contractList = (List<CommonContractEntity>)net.sf.json.JSONArray.toList(array, CommonContractEntity.class);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM