Attention

TYPO3 v9 has reached its end-of-life September 30th, 2021 and is not maintained by the community anymore. Looking for a stable version? Use the version switch on the top left.

You can order Extended Long Term Support (ELTS) here: TYPO3 ELTS.

format.json

Wrapper for PHPs json_encode function. See https://www.php.net/manual/function.json-encode.php.

Examples

Encoding a view variable

{someArray -> f:format.json()}

["array","values"] Depending on the value of {someArray}.

Associative array

{f:format.json(value: {foo: 'bar', bar: 'baz'})}

{"foo":"bar","bar":"baz"}

Non associative array with forced object

{f:format.json(value: {0: 'bar', 1: 'baz'}, forceObject: true)}

{"0":"bar","1":"baz"}

Arguments

value

DataType

mixed

Required

false

Description

The incoming data to convert, or null if VH children should be used

forceObject

DataType

mixed

Required

false

Description

Outputs an JSON object rather than an array