我的代码具有这样的Json响应
["0","0","0","0","0","0","204.4"]
需要这样
[ 0, 0, 0, 0, 0, 0, 204.4 ]
为此,我完成了codeigniter
$query = $this->db->query($selectQuery);
$totalInvoice = array();
foreach ($query->result() as $row)
{
$totalInvoice[] = $row->total;
}
print_r(json_encode($totalInvoice));
此回复为
["0","0","0","0","0","0","204.4"]
答案 0 :(得分:1)
在json中编码时添加 JSON_NUMERIC_CHECK(整数)。
JSON_NUMERIC_CHECK(整数):将数字字符串编码为数字
$query = $this->db->query($selectQuery);
$totalInvoice = array();
foreach ($query->result() as $row)
{
$totalInvoice[] = $row->total;
}
print_r(json_encode($totalInvoice, JSON_NUMERIC_CHECK);