用print_r列印出來的數組是這樣的:
Array( [total] => 8 [rows] => Array ( [0] => Array ( [id] => 1 [email] => 379395979@qq.com [activated] => 1 [username] => yuan [created_at] => 2014-03-04 02:30:43
為什麼使用json_encode輸出之後其他的資料都好的,就只有activated這個欄位會把1的變成true,0的變成false,有人遇到過這個情況嗎?該怎麼解決才能輸出原始的值。。。
架構是laravel4
json值像這樣:
{"total":8,"rows":[{"id":1,"email":"379395979@qq.com","activated":true,"activated_at":null,"last_login":"2014-04-03 05:41:30","username":"yuan","created_at":"2014-03-04 02:30:43"}
回複內容:
用print_r列印出來的數組是這樣的:
Array( [total] => 8 [rows] => Array ( [0] => Array ( [id] => 1 [email] => 379395979@qq.com [activated] => 1 [username] => yuan [created_at] => 2014-03-04 02:30:43
為什麼使用json_encode輸出之後其他的資料都好的,就只有activated這個欄位會把1的變成true,0的變成false,有人遇到過這個情況嗎?該怎麼解決才能輸出原始的值。。。
架構是laravel4
json值像這樣:
{"total":8,"rows":[{"id":1,"email":"379395979@qq.com","activated":true,"activated_at":null,"last_login":"2014-04-03 05:41:30","username":"yuan","created_at":"2014-03-04 02:30:43"}
使用 var_dump 查看資料來源頭的類型,LZ 列印結果不同,問題出在資料來源,如果資料表沒有問題,應該是從資料庫擷取資料出來的資料格式有問題。
json_encode沒有改變bool的值
..
剛才理解錯誤了
測試了一下,沒發現json_encode有改變...
Laravel源碼也沒找著轉換的地方..