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;