PHP Version: 5.6.15RC1
Compiler: MSVC11 (Visual C++ 2012)
Architecture:x86
I am having problem json_encode ing a multi dimensional php array. The main problem is that no error is generated (json_last_error=0).
The array is indexed by a string and testing each of these indexes seperately has been done within the array compilation has been done on the outer indexes by using:
$test = json_encode($account[$q_id]);
if (strlen($test) < 2) {
$error = json_last_error();
}
Stepping through several showed correct json output. Then a breakpoint in the if statement was placed to identify any encoding issues, however it never stopped on the $error... line.
Database connection:
$connection_cfg = array("Database" => $db["database"], "CharacterSet" => "UTF-8", "UID" => $db["uname"], "PWD" => $db["pword"], "ReturnDatesAsStrings" =>true);
$this->connection = sqlsrv_connect($db["host"], $connection_cfg);
I am stuck on how to proceed to debug this.
答案 0 :(得分:0)
空的JSON字符串如下所示:
[]
这是2个字符。 您的错误检测将无法正常工作,因为它会检查1个或更少的字符。
更改
if (strlen($test) < 2) {
$error = json_last_error();
}
要
if (strlen($test) == 2) {
$error = json_last_error();
}
您的错误检测应该有效。
如果您无法解决JSON错误中指出的问题,请通过错误更新我们。
答案 1 :(得分:-1)
var a=<?php echo $thejsonstuff ?>
我首先尝试从netbeans结果进行php调试。