Joey Hipolito
Joey Hipolito

Reputation: 3166

Using GSON to parse Arraylist of ArrayList

I don't know why java has no native json parser, pretty odd, and I cam across different jars just now, like GSON, but I am still relatively new to it.

When I try to system.out.println my query:

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

I am getting this kind of list

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

How to i send this back to the browser as json?

Upvotes: 1

Views: 172

Answers (1)

Prabhakaran Ramaswamy
Prabhakaran Ramaswamy

Reputation: 26084

Gson gson = new Gson();
String json = gson.toJson(this.db.fetchAll(query));

Upvotes: 1

Related Questions