不带双引号的PHP编码列_id

不带双引号的PHP编码列_id,php,mysql,json,encoding,Php,Mysql,Json,Encoding,使用以下脚本将数据库数据编码为JSON: if (mysql_num_rows($result) > 0) { $response["detail"] = array(); while ($row = mysql_fetch_array($result)) { // temp user array $item = array(); $item["_id"] = $row["_id"];

使用以下脚本将数据库数据编码为JSON:

if (mysql_num_rows($result) > 0) {

    $response["detail"] = array();

    while ($row = mysql_fetch_array($result)) {
            // temp user array
            $item = array();
            $item["_id"] = $row["_id"];

            array_push($response["detail"], $item);
           }
      // success
     $response["success"] = 1;
}

// echoing JSON response
echo json_encode($response);
得到这样的回应:

{"detail":[{"_id":"3"}],"success":1}
而我正期待着这一次:

{"detail":[{"_id":3}],"success":1}
5.3.0中引入的JSON_NUMERIC_CHECK标志

请阅读此了解更多信息

您可以键入强制转换int-id

5.3.0中引入的JSON_NUMERIC_CHECK标志

请阅读此了解更多信息

您可以键入强制转换int-id


谢谢:勾选为有用并将在五分钟内接受谢谢:勾选为有用并将在五分钟内接受
echo json_encode( $response, JSON_NUMERIC_CHECK );
 $item["_id"] = (int) $row["_id"];