JSONArray json = new JSONArray();
JSONObject object = null;
int total = 0;
while (rs.next()) {
object = new JSONObject();
object.put("state", "暂缺");
object.put("carNo; ", rs.getString("LEASTS"));
object.put("model", rs.getString("MODEL"));
object.put("custPo", rs.getString("BADCATEGORY"));
object.put("custName", rs.getString("CUSTOMCODE"));
object.put("shipPcs", rs.getString("SHIPPCS"));
object.put("numberPcs", rs.getString("NUMBERPCS"));
object.put("numberSet", rs.getString("NUMBERSET"));
object.put("badDesc", rs.getString("BADDESC"));
total = total + 1;
json.put(object);
}
rs.close();
stmt.close();
JSONArray data = new JSONArray();
object = new JSONObject();
object.put("total", String.valueOf(total));
object.put("rows", json);
data.put(object);
PrintWriter out = response.getWriter();
response.setCharacterEncoding("UTF-8");
out.println(data.toString().replaceAll("\\\\", ""));
out.println(jsonstr.substring(1, jsonstr.length() - 1));
out.close();
org.json.JSONArray LIST转JSON
最新推荐文章于 2022-11-11 10:20:23 发布