Public
Authored by animate.rene.elsaesser

[TYPO3][Extbase][JSON] Ajax Response mit einem Model

Objekte, die JsonSerializable implementieren, können ihre JSON-Darstellung anpassen, wenn sie mit json_encode codiert sind.

Im Controller:

/**
 * ajaxAction
 * @return string
 */
public function ajaxAction () {
    ...
    /* @var $address Vendor\Extension\Domain\Model\Address */
    foreach ($customer->getAddress() as $address) {
        $response[] = $address;
    }
    return json_encode($response);
}
Address.php 1.34 KB
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment