I am returning a dataset from database in List and converting them into a JSON as below.
List<DensityGroup> dg = pdao.getProductPropListData("Density");
String data = new Gson().toJson(dg);
System.out.println(data);
I am facing below problems:
1. System.out is printing the following in console.
[
{"densityId":"11","densityDescription":"Mcvr"},
{"densityId":"14","densityDescription":"test"}
]
I am getting the below response into browser with escape characters (I am making an AJAX call)
{"data":"[{\"densityId\":\"11\",\"densityDescription\":\"Mcvr\"},{\"densityId\":\"14\",\"densityDescription\":\"test\"}]"}
2. I need the following format. The extra quotes before [ is making my dataTable a mess-up.
{
"data": [
{"densityId":"11","densityDescription":"Mcvr"},
{"densityId":"14","densityDescription":"test"}
]
}
3. I don't need the escaping quotes before every double quotes in my current output. Please help me.

