Re: json_encode ignores protected/private class members

From: Date: Thu, 09 Oct 2008 13:31:54 +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-40890@lists.php.net to get a copy of this message
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 local scope or inheriting the object you shouldn't be able to see those variables. And I have yet to see classs Name extends json_decode($jsonValues) { } That's the point in having access modifiers. Unless I'm mistaking there's no bug there.
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 string is not totally crazy. 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. regards, Lukas Kahwe Smith mls@pooteeweet.org

« previous php.internals (#40890) next »