1
我的Google Json arrylist返回0值,但不应该。Google Json arraylist返回0值
我不想回这个值,它具有这样的:
这一点 - “总”:0, “记录”:0, “页”:0, “行”:0,
下面的代码返回数组:
[
{
"message":"sdfghjkl",
"total":0,
"records":0,
"page":0,
"rows":0
},
{
"message":"knee problem",
"total":0,
"records":0,
"page":0,
"rows":0
},
{
"message":"hip problem",
"total":0,
"records":0,
"page":0,
"rows":0
},
{
"message":"patient message",
"total":0,
"records":0,
"page":0,
"rows":0
},
{
"message":"hip problem 2-12-2015",
"total":0,
"records":0,
"page":0,
"rows":0
},
{
"message":"hip problem 12-2015",
"total":0,
"records":0,
"page":0,
"rows":0
}
]
代码:
Gson gson = new Gson();
List<PatientDto> all_pati_message = new ArrayList<PatientDto>();
String sql = "";
try {
sql = "SELECT message from patient_mess";
ResultSet rs;
rs = DatabaseConn.getConnection().createStatement().executeQuery(sql);
while (rs.next()) {
PatientDto dto1 = new PatientDto();
dto1.setMessage(rs.getString(1));
all_pati_message.add(dto1);
}
} catch (Exception e) {
e.printStackTrace();
}
String jsonString = gson.toJson(all_pati_message);
return jsonString;