Sign in

About JSON in PHP_ The exotic problem of encode

Jamie edited in Thu, 28 Apr 2022

For example: there is an array found from the database. Normally, echo Josn is used_ Encode ($a); the output JSON string should be


As mentioned above, double quotation marks will be added to the output of integer fields in the database, but this is the output of another server recently


Integer values such as 1,23 have no double quotation marks. It's very strange. I don't know what's going on. Does the God know

3 Replies
commented on Thu, 28 Apr 2022

Please check in Josn_ Encode ($a); before var_ Dump ($a)

commented on Thu, 28 Apr 2022

Maybe it's a database problem on another server. The landlord can check whether it's a database problem or a PHP problem


commented on Fri, 29 Apr 2022

First, make sure that the output in the database is quoted? My feeling is that ID is generally an integer, and the database output will also be an integer, so JSON is also an integer, so I don't think the problem is caused by JSON. The zval at the bottom of PHP defines a type for you, so JSON won't be idle to change the type for you. That's a lot of trouble, so see if the database output is an integer

lock This question has been locked and the reply function has been disabled.