Not able to draw charts by converting arraylist<Product> of products to JsonArraay and passing to datatable

70 views
Skip to first unread message

Rohit Singh

unread,
May 12, 2012, 5:51:13 AM5/12/12
to Google Chart API
Hi All,

I am querying DB and populating Products in an arraylist then i am
converting them to JsonArray
here is a snippet

ArrayList<ProductTest> list= pimpl.getProductList(productId,
startDate, endDate);
Gson gson = new Gson();
String json = gson.toJson(list);
JsonParser parser = new JsonParser();
JsonArray array = parser.parse(json).getAsJsonArray();

on client side (JSP) i am trying to pass this array to datatable
var data = new google.visualization.DataTable(<%=array%>);

it is giving no table no columns however the array prints
[{"product_id":0,"unique_visitors":9237},{"product_id":
1,"unique_visitors":237},{"product_id":2,"unique_visitors":3000},
{"product_id":3,"unique_visitors":3000},{"product_id":
4,"unique_visitors":3000}] on console is there anything wrong in this
code ?

Please help
Reply all
Reply to author
Forward
0 new messages