protected function json($data, bool $encode = true) : Response
    {
        if ($encode) {
            $data = json_encode($data);
        }

        return $this->createResponse($data, 'application/json');
    }
protected function json($data, bool $encode = true) : Response
    {
        if ($encode) {
            $data = json_encode($data);
        }

        return $this->createResponse($data, 'application/json');
    }
protected function json ( $ data , bool $ encode = true ) : Response { if ( $ encode ) { $ data = json_encode ( $ data ) ; } return $ this -> createResponse ( $ data , 'application/json' ) ; }
Returns a JSON response.

@param mixed $data   The data to encode, or a valid JSON string if `$encode` == `false`.
@param bool  $encode Whether to JSON-encode the data.

@return \Brick\Http\Response
Returns a JSON response .