Hi ScaNNeR, Cool, thanks for your help.
Regards, JoJo 2010/2/2 ScaNNeR <scanne...@gmail.com> > For JSON exchange I doing special module 'json' named. > Addition I create "config" folder for "json" module and create > "view.yml" whithout template. > My actions sample: > > public function executeNewChart(sfWebRequest $request) { > $retData = array(); > /* > only ajax request > */ > if ($request->isXmlHttpRequest()) { > /* any manipulation data */ > $this->getUser()->setAttribute('statYear', $request- > >getParameter('statChartType', 'p3') ); > $retData['statYear'] = $this->getUser()->getAttribute > ('year', date('Y', time() ) ); > $retData['statView'] = $this->getUser()->getAttribute > ('statView', 'toCommon'); > $retData['statTypeService'] = $this->getUser()- > >getAttribute('statTypeService', 'hosting'); > $retData['statChartType'] = $request->getParameter > ('statChartType'); //$newReport->createStatData($this->getUser()- > >getAttribute('statTypeService')); > $newReport = new statHarvester( $this->getUser()- > >getAttribute('statTypeService'), $request->getParameter('year')); > $retData['newReport'] = ''; > /* create JSON*/ > $retData = json_encode( $retData ); > /* Prepare JSON data */ > $this->renderText( $retData ); > } > // without template and RETURN > return sfView::NONE; > } > > You remember, if use "dev" env - Symfony send add information, can > destroy JSON data - use "PROD" dev for testing and debug. > > Sorry for my english, but I think what my understand. > > > On 1 фев, 12:57, Dong YANG <jojoyangd...@gmail.com> wrote: > > 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 <d.spa...@d-down.de> > > > > > If you use Doctrine try > > > > > json_encode($this->test->toArray()); > > > > > On 28 Jan., 23:39, Eno <symb...@gmail.com> 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 symfony-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com> > <symfony-users%2bunsubscr...@googlegroups.com<symfony-users%252bunsubscr...@googlegroups.com> > > > > > . > > > 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 symfony-us...@googlegroups.com. > To unsubscribe from this group, send email to > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com> > . > 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 symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.