Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40886 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43717 invoked from network); 9 Oct 2008 13:08:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Oct 2008 13:08:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=kenashkov@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kenashkov@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.134.190 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: kenashkov@gmail.com X-Host-Fingerprint: 209.85.134.190 mu-out-0910.google.com Received: from [209.85.134.190] ([209.85.134.190:52067] helo=mu-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/24-48736-3320EE84 for ; Thu, 09 Oct 2008 09:08:03 -0400 Received: by mu-out-0910.google.com with SMTP id i2so12666mue.3 for ; Thu, 09 Oct 2008 06:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=j/XN4FF1xAFjZ/J3BPS/yK0XfjMo5s9LRp66/too5Sw=; b=pWuiA58mkHLOBEtH57pl1KRzW/NKEM+/cs78EyZ974Mf/qPMdZAVQ7geYECqaRgpuv ttgGxkIfHJJnyK+vUHbyb9BBLNwyu9QrqjoELdkEzhWKWI5gfOz+RU0lqZkma4nBFF/J WNLzNyKKZioOk4jNUBg7OuWQD/hi/9QJWftok= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=mPhVFxevgkfbBjVHqLDR23kOxZRE2Gpqe3BRv1vstVF6Bbf0KaSD4eu1AjsAS/CmNQ /mHEaDKawM7RLn1ftFBrWYXMHfWfXt3grz2dB2vVBfufS2o7yVg+smOxdnGfVh/vs7VL GOjGJrdpuynO1wxhOYFHcatntvy/Ry8qPr4do= Received: by 10.142.217.19 with SMTP id p19mr15259wfg.348.1223557679339; Thu, 09 Oct 2008 06:07:59 -0700 (PDT) Received: by 10.142.76.6 with HTTP; Thu, 9 Oct 2008 06:07:59 -0700 (PDT) Message-ID: <261daaa10810090607h1876200ex1efa43a40cfb24c2@mail.gmail.com> Date: Thu, 9 Oct 2008 16:07:59 +0300 To: "Jarismar Chaves da Silva" Cc: internals@lists.php.net In-Reply-To: <48EDFEED.8080605@adplabs.com.br> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_11794_26050401.1223557679301" References: <48EDFEED.8080605@adplabs.com.br> Subject: Re: [PHP-DEV] json_encode ignores protected/private class members From: kenashkov@gmail.com ("Vesselin Kenashkov") ------=_Part_11794_26050401.1223557679301 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 < jarismar_silva@adplabs.com.br> 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 > > ------=_Part_11794_26050401.1223557679301--