[TYPO3-mvc] Making JSON data from object

Andreas Lappe nd at off-pist.de
Thu Mar 4 14:15:58 CET 2010


On  4.03.10, Pascal Geldmacher wrote:
> $orders = $this->orderRepository->findAll();
> $results = array();
> foreach($orders as $order){
> 	$orderArray = array();
> ...

I do use the following in my view:

public function render() {
    if($this->objName !== NULL) {
        $this->data = (array) $this->data;
        foreach($this->data as $key=>$value) {
            $newkey =
                'tx_ndlibrary_ajax['.$this->objName.']['.$key.']';
            $this->data[$newkey] = $value;
            unset($this->data[$key]);
        }
    }
    $arr = array("success" => $this->success,
            "data" => $this->data);
    return json_encode($arr);
}

That worked fine for me, though not really better... :)

So long
Andy


-- 
,,Im Zweifelsfall sollte man sich für das Leben entscheiden.´´
						-Terry Pratchett


More information about the TYPO3-project-typo3v4mvc mailing list