Webiny\Component\Http\Response\JsonResponse::__construct PHP Method

__construct() public method

Base constructor.
public __construct ( string | array | ArrayObject $content, array $headers = [], boolean $prettyPrint = false )
$content string | array | Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject Json content.
$headers array Headers to attach to the response.
$prettyPrint boolean Should we use JSON_PRETTY_PRINT to nicely format the output.
    public function __construct($content, $headers = [], $prettyPrint = false)
    {
        if (StdObjectWrapper::isArrayObject($content)) {
            $content = $this->jsonEncode($content->val(), $prettyPrint ? JSON_PRETTY_PRINT : 0);
        } else {
            if ($this->isArray($content) || $this->isObject($content)) {
                $content = $this->jsonEncode($content, $prettyPrint ? JSON_PRETTY_PRINT : 0);
            }
        }
        parent::__construct($content, 200, $headers);
        $this->setContentType('application/json');
    }