Neos\FluidAdaptor\ViewHelpers\Format\JsonViewHelper::render PHP Method

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.
    public function render($value = null, $forceObject = false)
    {
        return self::renderStatic(array('value' => $value, 'forceObject' => $forceObject), $this->buildRenderChildrenClosure(), $this->renderingContext);
    }

Usage Example

 /**
  * @test
  */
 public function viewHelperEscapesGreaterThanLowerThanCharacters()
 {
     $this->assertEquals('["\\u003Cfoo\\u003E","bar","elephant \\u003E mouse"]', $this->viewHelper->render(array('<foo>', 'bar', 'elephant > mouse')));
     $this->assertEquals('{"0":"\\u003Cfoo\\u003E","1":"bar","2":"elephant \\u003E mouse"}', $this->viewHelper->render(array('<foo>', 'bar', 'elephant > mouse'), true));
 }