Hi Eno and Dejan,
Thanks for your replies, I found why I got always empty when calling
json_encode in this method, in fact, the object returnd by
$this->getRoute()->getObject() contains only protected and privated members,
and json_encode treats only public members, so as result I got always '{}'.
Help this can help others.
Regards,
JoJo
2010/1/29 Dejan Spasic <[email protected]>
> If you use Doctrine try
>
> json_encode($this->test->toArray());
>
> On 28 Jan., 23:39, Eno <[email protected]> wrote:
> > On Thu, 28 Jan 2010, Dong YANG wrote:
> > > Hi everyone,
> >
> > > I passed many hours for this strange thing, in fact I got a problem
> when
> > > using json_encode in symfony.
> >
> > > In my front-end module, method executeIndex() as below:
> >
> > > public function executeIndex(sfWebRequest $request)
> > > {
> > > $this->test = $this->getRoute()->getObject();
> > > // Call json_encode, but return '{}'
> > > $json = json_encode($this->test);
> >
> > > // this simple test works
> > > $test = new stdClass();
> > > $test->id = new stdClass();
> > > var_dump(json_encode($test));
> > > }
> >
> > What happens if you do this?
> >
> > $test = $this->getRoute()->getObject();
> > $json = json_encode($test);
> > $this->test = $test;
> >
> > --
>
> --
> You received this message because you are subscribed to the Google Groups
> "symfony users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<symfony-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en.