2008/10/9 Rodrigo Saboya <[EMAIL PROTECTED]>: > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
A simply userland solution would be to use an abstract base class with json_encode()/json_decode() as public final methods. All classes needing to support json_encode/json_decode would simply need to extend from this base class. No need to add even more "magic" to the base stdClass. Richard. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php