Hey,
I am trying to convert an array to a JSON string, which can be assigned to a Google Visualization datatable.
However, whatever I try, I keep getting errors. Even with the example of Google Visualization API!
This is what I have:
String haha = "{" +
" cols: [{id: 'task', label: 'Task', type: 'string'}," +
" {id: 'hours', label: 'Hours per Day', type: 'number'}]," +
" rows: [{c:[{v: 'Work'}, {v: 11}]}," +
" {c:[{v: 'Eat'}, {v: 2}]}," +
" {c:[{v: 'Commute'}, {v: 2}]}," +
" {c:[{v: 'Watch TV'}, {v:2}]}," +
" {c:[{v: 'Sleep'}, {v:7, f:'7.000'}]}" +
" ]" +
" }";
JSP: var view = new google.visualization.DataTable(${chartData});
What I get is an error, telling me that the JSON format is invalid.
The goal is to save a hashmap to a datatable with JSON (hashmap contains a category and a value). The above example was used as I cannot seem to build a proper JSON format myself. But this doesn't work as well.
Hopefully someone can help me. Thanks in advance