My end result needs to be something like this:
[{
"label": "Sales",
"color": "#9cd159",
"data": [
["Jan", 27],
["Feb", 82],
["Mar", 56],
["Oct", 20]
]
}]
my apex is as follows:
class Report {
public String label;
public String color;
public Data[] data;
}
class Data{
public String key;
public Integer value;
}
my json serialize class is this:
public String ReportOne{
Report myReport = new Report();
myReport.label = 'Sales';
myReport.color = '#9cd159';
myReport.data = new Data[]{};
Data d1 = new Data();
d1.key = 'Mon';
d1.value = 13;
myReport.data.add(d1);
return JSON.serialize(myReport);
}
The end result is being like this: What am I doing wrong?
{
"color": "#9cd159",
"data": [
{
"key": "Mon",
"value": 13
}
],
"label": "Sales"
}