Questions tagged «redbean»

9
在PHP中的对象上使用json_encode(无论范围如何)
我正在尝试将对象列表输出为json,并想知道是否有一种使对象可用的方法json_encode?我得到的代码看起来像 $related = $user->getRelatedUsers(); echo json_encode($related); 现在,我只是遍历用户数组,并将它们分别导出到数组中,json_encode以便对我来说变成可用的json。我已经尝试过使对象可迭代,但是json_encode无论如何似乎都跳过它们。 编辑:这是var_dump(); php > var_dump($a); object(RedBean_OODBBean)#14 (2) { ["properties":"RedBean_OODBBean":private]=> array(11) { ["id"]=> string(5) "17972" ["pk_UniversalID"]=> string(5) "18830" ["UniversalIdentity"]=> string(1) "1" ["UniversalUserName"]=> string(9) "showforce" ["UniversalPassword"]=> string(32) "" ["UniversalDomain"]=> string(1) "0" ["UniversalCrunchBase"]=> string(1) "0" ["isApproved"]=> string(1) "0" ["accountHash"]=> string(32) "" ["CurrentEvent"]=> string(4) "1204" ["userType"]=> string(7) "company" …
75 php  json  scope  redbean 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.