I am trying to generate a chart using Google Charts API, but I can’t seem to get the data in the required format.
serializeJSON(data) in coldfusion gives me the JSON data, but looks like that is not what the Charts API expects. Is there any component I can use to convert it to the required format?
Query
<cfquery name="getAllUsers" datasource="cccac_swipe" result="UserDetailsResult">
Select login_mode,count(login_mode) as total from login_activity,ccac_registered_users where login_activity.student_id=ccac_registered_users.student_id GROUP BY login_mode
</cfquery>
ColdFusion’s JSON
{"COLUMNS":["LOGIN_MODE","TOTAL"],"DATA":[["manual",123],["swipe",20]]}
Expected JSON
{ "cols": [ {"id":"","label":"SignIn Method","pattern":"","type":"string"}, {"id":"","label":"Count","pattern":"","type":"number"} ], "rows": [ {"c":[{"v":"manual","f":null},{"v":123,"f":null}]}, {"c":[{"v":"swipe","f":null},{"v":20,"f":null}]} ] }
This is basically what you need. Just plug in your query data.