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