Issue Bug Closed

#66581Extbase - JsonView: wrong key encoding in array

Thilo Schumann 04/24/15, 18:28 updated 02/08/23, 16:05

Description

If the array key is of type string, then the PHP function json_encode converts it to named objects instead of an array.
Extbase internal reference identifiers are encoded of type string instead of integer.

The bug is here in case of ‘_descendAll’ https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/extbase/Classes/Mvc/View/JsonView.php#L255

FIX: convert the key to integer

Change from:

$array[$key] = $this->transformValue($element, $configuration['_descendAll']);

to:

$array[hexdec($key)] = $this->transformValue($element, $configuration['_descendAll']);

Reviews 1