I have the model class to return a JSON output with two array values, one array containing int values and another with single quotes words.
class RGraph{
int[] data;
String[] labels;
// getters and setters
}
When I return the RGraph class as JSON response from Spring controller with @ResponseBody
, I get the following result as json o/p,
{
"data":[8,46,96,1,18,65,84,13,72,60],
"label":["Gary","Olga","Lewis","Rachel","Nathan","Matt","Kevin","Indigo","Lou","Pete"]
}
But what my expected output is,
{
data:[12,43,64,57,49,35,75,58,94,63],
labels: ['Gary','Olga','Lewis','Rachel','Nathan','Matt','Kevin','Indigo','Lou','Pete']
}
In the above JSON response, I have two questions
- How to remove the double quotes for keys? and
- How to replace double quotes with single quotes in values?
I need this format because RGraph Chart library expects the values with single quotes for its labels and tooltips.