1

我不知道为什么 java 没有原生的 json 解析器,很奇怪,而且我刚刚跨过不同的 jar,比如 GSON,但我对它还是比较陌生。

当我尝试system.out.println查询时:

 System.out.println(this.db.fetchAll(query));

我得到了这样的清单

[[1, user, pass], [2, another, test], [3, argh, test]]

如何将其作为 json 发送回浏览器?

4

1 回答 1

1
Gson gson = new Gson();
String json = gson.toJson(this.db.fetchAll(query));
于 2013-10-19T01:46:04.700 回答