Is JSON encode forcing strings instead of Integers?
Hello,
I have this MySQLi query that returns results for a Charting application
<?php
$LeadsChart = new WA_MySQLi_RS("LeadsChart",$high_i,0);
$LeadsChart->setQuery("SELECT CAST(SUM(MID)AS DECIMAL) AS y, CONCAT( LEFT(MONTHNAME(lddate), 3), ' ', YEAR(lddate)) AS label FROM tblleads WHERE mid = 1 AND lddate > 1 GROUP BY CONCAT( LEFT(MONTHNAME(lddate), 3), ' ', YEAR(lddate)), YEAR(lddate), MONTH(lddate) ORDER BY YEAR(lddate), MONTH(lddate) ASC");
$LeadsChart->execute();
?>
I've CAST the y value as UNSIGNED and DECIMAL but in each case the JSON Encode renders the result inside a double quote. This is preventing execution where actual numbers are needed to render the chart.
data: [
{
type: "spline",
dataPoints: <?php echo json_encode($LeadsChart ->Results); ?>
}
]
Result:
data: [
{
type: "spline",
dataPoints: [{"y":"29","label":"Jan 2016"},{"y":"24","label":"Feb 2016"},{"y":"40","label":"Mar 2016"},{"y":"32","label":"Apr 2016"},{"y":"28","label":"May 2016"},{"y":"38","label":"Jun 2016"},{"y":"37","label":"Jul 2016"},{"y":"29","label":"Aug 2016"},{"y":"21","label":"Sep 2016"},{"y":"22","label":"Oct 2016"},{"y":"16","label":"Nov 2016"},{"y":"15","label":"Dec 2016"},{"y":"19","label":"Jan 2017"},{"y":"29","label":"Feb 2017"},{"y":"33","label":"Mar 2017"},{"y":"28","label":"Apr 2017"},{"y":"23","label":"May 2017"},{"y":"27","label":"Jun 2017"},{"y":"27","label":"Jul 2017"},{"y":"20","label":"Aug 2017"},{"y":"31","label":"Sep 2017"},{"y":"26","label":"Oct 2017"},{"y":"27","label":"Nov 2017"},{"y":"14","label":"Dec 2017"},{"y":"22","label":"Jan 2018"},{"y":"26","label":"Feb 2018"},{"y":"31","label":"Mar 2018"},{"y":"28","label":"Apr 2018"},{"y":"2","label":"May 2018"},{"y":"17","label":"Jun 2018"},{"y":"41","label":"Jul 2018"},{"y":"20","label":"Aug 2018"}] }
]
Is there something in the way the Recordset Results are rendered that block or reassign the int as a string?