Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40887 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45179 invoked from network); 9 Oct 2008 13:12:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Oct 2008 13:12:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=jarismar_silva@adplabs.com.br; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jarismar_silva@adplabs.com.br; sender-id=pass Received-SPF: pass (pb1.pair.com: domain adplabs.com.br designates 201.84.224.135 as permitted sender) X-PHP-List-Original-Sender: jarismar_silva@adplabs.com.br X-Host-Fingerprint: 201.84.224.135 mx.adplabs.com.br Linux 2.6 Received: from [201.84.224.135] ([201.84.224.135:35172] helo=mx.adplabs.com.br) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/74-48736-A530EE84 for ; Thu, 09 Oct 2008 09:12:59 -0400 Received: from kafe.adplabs.com.br (mail.adplabs.com.br [201.84.224.133]) by mx.adplabs.com.br (Postfix) with ESMTP id F3D5C4E4183; Thu, 9 Oct 2008 10:12:55 -0300 (BRT) Received: from [10.159.1.169] (jarismar.adplabs.com.br [10.159.1.169]) by kafe.adplabs.com.br (Postfix) with ESMTP id 385E7415968; Thu, 9 Oct 2008 10:12:51 -0300 (BRT) Message-ID: <48EE0387.3040802@adplabs.com.br> Date: Thu, 09 Oct 2008 10:13:43 -0300 User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Vesselin Kenashkov CC: internals@lists.php.net References: <48EDFEED.8080605@adplabs.com.br> <261daaa10810090607h1876200ex1efa43a40cfb24c2@mail.gmail.com> In-Reply-To: <261daaa10810090607h1876200ex1efa43a40cfb24c2@mail.gmail.com> Content-Type: multipart/alternative; boundary="------------020104000008010507090108" X-ADPLabs-MailScanner-Information: Please contact your ISP for more information X-ADPLabs-MailScanner: Found to be clean X-ADPLabs-MailScanner-From: jarismar_silva@adplabs.com.br X-Spam-Status: No Subject: Re: [PHP-DEV] json_encode ignores protected/private class members From: jarismar_silva@adplabs.com.br (Jarismar Chaves da Silva) --------------020104000008010507090108 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: > class c1 > { > protected $p1 = 'aa'; > public $p2 = 'bb'; > public function enc() > { > //print $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 > > > wrote: > > Hi internals, > > Does anyone knows why json_encode ignores protected/public class > members ? > I've searching about it on documentation an mailing lists but > found nothing but workarounds. > Until now I'm forced to change my classes to use public members > when I need to send a PHP object on e.g. AJAX responses. It would > be nice if json_encode also send those attributes or at least have > a parameter to whether send non-public attributes or not. > > Thanks in advance. > Jaris. > > -- > > *Jarismar Chaves da Silva, M.Sc.* > > *ADP**Labs** Brazil** > *jarismar_silva@adplabs.com.br > > > > http://www.adp.com > > -- *Jarismar Chaves da Silva, M.Sc.* *ADP**Labs** Brazil** *+55 51 3327 1491 – Direct +55 51 9947 3613 – Mobile jarismar_silva@adplabs.com.br http://www.adp.com This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system. --------------020104000008010507090108--