如何删除 Json 响应中的双引号
How to Remove Double Quotes in Json Response
我的代码有 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"]
在 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);
我的代码有 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"]
在 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);