草庐IT

ProductComment

全部标签

PHP json_encode 不适用于对象数组

我正在开发php应用程序,我在其中查询数据库并将生成的结果发送回html客户端。目前,我正在使用php函数json_encode获取我在JSON中编码的对象数组。但是在编码之后,我的结果中得到了空数组。以下是编码为JSON之前的结构array(2){[0]=>object(ProductComment)#6(2){["_productId":"ProductComment":private]=>string(1)"1"["_commentArray":"ProductComment":private]=>array(2){[0]=>array(3){["comment"]=>strin