PHP Class Neos\FluidAdaptor\ViewHelpers\Format\JsonViewHelper

= Examples = {someArray -> f:format.json()} ["array","values"] depending on the value of {someArray} {f:format.json(value: {foo: 'bar', bar: 'baz'})} {"foo":"bar","bar":"baz"} {f:format.json(value: {0: 'bar', 1: 'baz'}, forceObject: true)} {"0":"bar","1":"baz"}
Inheritance: extends Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper
Show file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$escapeChildren boolean

Public Methods

Method Description
render ( mixed $value = null, boolean $forceObject = false ) : string Outputs content with its JSON representation. To prevent issues in HTML context, occurrences of greater-than or less-than characters are converted to their hexadecimal representations.
renderStatic ( array $arguments, Closure $renderChildrenClosure, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : string Applies json_encode() on the specified value.

Method Details

render() public method

If $forceObject is TRUE a JSON object is outputted even if the value is a non-associative array Example: array('foo', 'bar') as input will not be ["foo","bar"] but {"0":"foo","1":"bar"}
See also: http://www.php.net/manual/en/function.json-encode.php
public render ( mixed $value = null, boolean $forceObject = false ) : string
$value mixed The incoming data to convert, or NULL if VH children should be used
$forceObject boolean Outputs an JSON object rather than an array
return string the JSON-encoded string.

renderStatic() public static method

Applies json_encode() on the specified value.
public static renderStatic ( array $arguments, Closure $renderChildrenClosure, TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext ) : string
$arguments array
$renderChildrenClosure Closure
$renderingContext TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
return string

Property Details

$escapeChildren protected property

protected bool $escapeChildren
return boolean