JSON data returned in a local environment using LARAVEL3 is normal
For example {"id": 1}
But the data returned after uploading the code to the development machine becomes
{"id": "1"}
is all the value plus double quotes, all become a string type, very strange, do not know is the server Apache setup problem or what?
Header head is already content-type Application/json; Charset=utf-8
Local environment PHP5.4 MySQL 5.6
Development machine Environment PHP5.3 MySQL 5.0
Currently tentative question is PHP5.3 link MySQL driver problem php from 5.3 can be native return MySQL field type,
http://stackoverflow.com/questions/1197005/how-to-get-numeric-types-from-mysql-using-pdo#answer-1197041
Now the problem is to install MYSQLND on Centos6.4, the PHP5.3, but the default package inside No, do not know how to install?
http://stackoverflow.com/questions/13159518/how-to-enable-mysqlnd-for-php
Reply content:
JSON data returned in a local environment using LARAVEL3 is normal
For example {"id": 1}
But the data returned after uploading the code to the development machine becomes
{"id": "1"}
is all the value plus double quotes, all become a string type, very strange, do not know is the server Apache setup problem or what?
Header head is already content-type Application/json; Charset=utf-8
Local environment PHP5.4 MySQL 5.6
Development machine Environment PHP5.3 MySQL 5.0
Currently tentative question is PHP5.3 link MySQL driver problem php from 5.3 can be native return MySQL field type,
http://stackoverflow.com/questions/1197005/how-to-get-numeric-types-from-mysql-using-pdo#answer-1197041
Now the problem is to install MYSQLND on Centos6.4, the PHP5.3, but the default package inside No, do not know how to install?
http://stackoverflow.com/questions/13159518/how-to-enable-mysqlnd-for-php
Should have nothing to do with Apache, is the problem of the program code, is not where to convert the number into a string?
Can you do the conversion to integer before the data is returned?
Self-answer, the current tentative is a mysql-driven thing, do not know if anyone has encountered it?
http://stackoverflow.com/questions/1197005/how-to-get-numeric-types-from-mysql-using-pdo#answer-1197041
Please post your PHP version, as well as the source of the parameters used when using Json_encode, because it is possible that your data source is a database, the type defined in the database is a string, and then in Json_encode, it becomes a string.
The PHP version I used was 5.4.23, and I did the Json_encode test directly with hard code:
'caiknife', 'age' => 18, 'height' => '175'];Zend_Debug::dump(json_encode($json));Zend_Debug::dump(Zend_Json::encode($json));
Output Result:
string '{"name":"caiknife","age":18,"height":"175"}' (length=43)string '{"name":"caiknife","age":18,"height":"175"}' (length=43)
Did you get the JSON object tostring when you returned?