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].
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.

Reply via email to