I have a problem, I'm trying to convert an SQLQuery object result (from Hibernate) to a JSON.
SQLQuery q = session.createSQLQuery("SELECT * FROM table");
List<javaBean> list = q.list();
Afterward I开发者_高级运维 would like to convert that into a pretty JSON that has all the attribute name.
What's a good strategy? thanks
You can use Google-gson: http://code.google.com/p/google-gson/, it's quite good for converting Java beans to json:
https://sites.google.com/site/gson/gson-user-guide#TOC-Object-Examples
You could hook up a JAX-RS service to return your bean as JSON. Take a look at Jersey.
精彩评论