Re: json_encode ignores protected/private class members
| From: | Rodrigo Saboya | Date: | Thu, 09 Oct 2008 21:43:00 +0000 |
| Subject: | Re: json_encode ignores protected/private class members | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-40899@lists.php.net to get a copy of this message | ||
Jarismar Chaves da Silva wrote:
I agree with you. But when using json_encode I believe the developer wants to transfer the complete object state, just like when using serialize. Serialize does see private/protected class members, while json_encode not. Javascript does not have class-accessors so why not convert protected/private to public javascript attributes.In theory only the public members are relevant to anyone except the object itself. If you need information about private/protected members you are either using the wrong visibility for your variables or using json for something it's not supposed to do. -- Rodrigo Saboya