Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-16 Thread Lukas Kahwe Smith
Hi, So I guess the conclusion is: Create a feature request ticket, take the information from this thread and put it into the ticket .. and ideally write a patch yourself or motivate someone else .. regards, Lukas -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-12 Thread Daniel Convissor
Hi Jaris: > I don't know if I'm using json_encode for something it's not supposed to > do. I'm using it to serialize an object to send it to another > runtime-environment in response to an remote call, just like what I can > do with SOAP, REST or RMI. In this context I don't see much sense i

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-10 Thread Richard Quadling
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

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-10 Thread Richard Quadling
2008/10/10 Jarismar Chaves da Silva <[EMAIL PROTECTED]>: > > > Rodrigo Saboya wrote: >> >> 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

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-10 Thread Jarismar Chaves da Silva
Rodrigo Saboya wrote: 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 n

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Rodrigo Saboya
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 s

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Jarismar Chaves da Silva
Yes, it like it too. Just like an OOP should be. Dave Ingram wrote: however changing this at this point would be a huge security issue, so if at all, it would need to be handled by an optional parameter that defaults to false. That would be unclean. If it's implemented in some way, j

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Jarismar Chaves da Silva
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/priv

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Dave Ingram
Ron Rademaker wrote: > Stefan Walk wrote: >> That would be unclean. If it's implemented in some way, json_encode >> should look for the implementation of some interface (JSONEncodable >> or something) providing encoding/decoding methods (similar to >> __sleep/__wakeup). > Looking at our current JSO

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Dave Ingram
>> however changing this at this point would be a huge security issue, so >> if at all, it would need to be handled by an optional parameter that >> defaults to false. >> > > That would be unclean. If it's implemented in some way, json_encode should > look for the implementation of some inte

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Stefan Walk
On Thursday 09 October 2008 15:13:43 Jarismar Chaves da Silva wrote: > Ok, nice solution, but I still don't see why json_encode ignores > protected/private class members. I mean, why we need this feature. Because, in theory, it shouldn't even be able to see those members? Regards, Stefan -- PH

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Ron Rademaker
Stefan Walk wrote: That would be unclean. If it's implemented in some way, json_encode should look for the implementation of some interface (JSONEncodable or something) providing encoding/decoding methods (similar to __sleep/__wakeup). Looking at our current JSON implementations, such an interfa

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Stefan Walk
On Thursday 09 October 2008 15:31:54 Lukas Kahwe Smith wrote: > well .. i think this is at least the common use case. then again, json > is an encoding format, and i expect that i can get the same object > state by decoding. so the expectation to also get non public > properties in the json encoded

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Lukas Kahwe Smith
On 09.10.2008, at 15:45, Dave Ingram wrote: 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. If you want to serialize an object, then use t

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Dave Ingram
I still don't see why json_encode ignores protected/private class members. I mean, why we need this feature. >>> >>> Because, in theory, it shouldn't even be able to see those members? >> >> Stefan's right. Unless you are in the local scope or inheriting the >> object you shouldn't be a

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Lukas Kahwe Smith
On 09.10.2008, at 15:26, David Coallier wrote: Ok, nice solution, but I still don't see why json_encode ignores protected/private class members. I mean, why we need this feature. Because, in theory, it shouldn't even be able to see those members? Stefan's right. Unless you are in the loca

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread David Coallier
>> Ok, nice solution, but I still don't see why json_encode ignores >> protected/private class members. I mean, why we need this feature. > > Because, in theory, it shouldn't even be able to see those members? > Stefan's right. Unless you are in the local scope or inheriting the object you should

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Jarismar Chaves da Silva
Ok, nice solution, but I still don't see why json_encode ignores protected/private class members. I mean, why we need this feature. Vesselin Kenashkov wrote: Until this gets fixed instead of declaring the properties public you can use a encode method like this: p1; return json_encode(get_

Re: [PHP-DEV] json_encode ignores protected/private class members

2008-10-09 Thread Vesselin Kenashkov
Until this gets fixed instead of declaring the properties public you can use a encode method like this: p1; return json_encode(get_object_vars($this));//this will encode the protected var } } $o = new c1; print $o->enc(); ?> On Thu, Oct 9, 2008 at 3:54 PM, Jarismar Chaves da Silva < [EMAIL