Zum Inhalt springen

JsonView doesn't assign descendant objects

Erstellt am 24. November 2015 · 1 Antwort · letzte Antwort am 25. November 2015

Tags: JavaScript & AJAX, Frage, English

majermi3 ·

Hi all,

I am having trouble using JsonView in TYPO3. Problem is that I don't get descendant objects of my "Camera" object.

public function listAction() {
	$this->view->setVariablesToRender(array('cameras'));
	$this->view->setConfiguration(array(
		'cameras' => array(
			'_descend' => array(
				'sensor' => array(
					'_descendAll' => array(
					)
				)
			)
		)
	));
	$this->view->assign('cameras', $this->cameraRepository->findAll());
}

Model looks like this:
Camera - title, sensor, type, provider
Sensor - title
Provider - title

In my json I want to get also sensor and provider for every listed camera. All I get is a title and type (simple strings).

Any idea what I am doing wrong?

Thanks.

majermi3 ·

So i found the solution.

correct configuration is:

$this->view->setConfiguration(array(
	'cameras' => array(
		'_descendAll' => array(
			'_descend' => array(
				'sensor' => array()
			)
		)
	)
));