Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
Format.json ViewHelper <f:format.json>
Wrapper for PHPs json_
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"}
Source code
Go to the source code of this ViewHelper: JsonViewHelper.php (GitHub).
Arguments
The following arguments are available for <f:
:
value
-
- Type
- mixed
The incoming data to convert, or null if VH children should be used
forceObject
-
- Type
- boolean
Outputs an JSON object rather than an array