1

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?

1 Answer 1

1
Gson gson = new Gson();
String json = gson.toJson(this.db.fetchAll(query));
Sign up to request clarification or add additional context in comments.

3 Comments

it produces [[ ], [ ], [ ]], intsead of [{ }, { }, { }] how to I fixe that
@JoeySalacHipolito Please look into it. I think you are getting the correct Json string. stackoverflow.com/questions/13992356/…
yeah, sorry i have mistaken

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.