protected function jsonResponse($data = null, array $headers = array(), array $httpHeaders = array())
    {
        $headers = array_replace_recursive(array(
            'status' => array(
                'code'    => 200,
                'message' => 'OK',
            ),
            'version' => 'v1',
        ), $headers);

        $data = array(
            'headers'  => $headers,
            'response' => $data,
        );

        // Debug data
        if (Config::get('app.debug', false) && Input::get('debug', false) == true) {
            $data['debug'] = $this->debugDatas();
        }

        $response = Response::make(json_encode($data), $headers['status']['code']);

        // HTTP headers
        foreach ($httpHeaders as $k => $v) {
            $response->header($k, $v);
        }
        $response
            ->header('Content-Type', 'application/json')
            ->setEtag(md5(json_encode($data)))
        ;

        return $response;
    }
protected function jsonResponse($data = null, array $headers = array(), array $httpHeaders = array())
    {
        $headers = array_replace_recursive(array(
            'status' => array(
                'code'    => 200,
                'message' => 'OK',
            ),
            'version' => 'v1',
        ), $headers);

        $data = array(
            'headers'  => $headers,
            'response' => $data,
        );

        // Debug data
        if (Config::get('app.debug', false) && Input::get('debug', false) == true) {
            $data['debug'] = $this->debugDatas();
        }

        $response = Response::make(json_encode($data), $headers['status']['code']);

        // HTTP headers
        foreach ($httpHeaders as $k => $v) {
            $response->header($k, $v);
        }
        $response
            ->header('Content-Type', 'application/json')
            ->setEtag(md5(json_encode($data)))
        ;

        return $response;
    }
protected function jsonResponse ( $ data = null , array $ headers = array ( ) , array $ httpHeaders = array ( ) ) { $ headers = array_replace_recursive ( array ( 'status' => array ( 'code' => 200 , 'message' => 'OK' , ) , 'version' => 'v1' , ) , $ headers ) ; $ data = array ( 'headers' => $ headers , 'response' => $ data , ) ; // Debug data if ( Config :: get ( 'app.debug' , false ) && Input :: get ( 'debug' , false ) == true ) { $ data [ 'debug' ] = $ this -> debugDatas ( ) ; } $ response = Response :: make ( json_encode ( $ data ) , $ headers [ 'status' ] [ 'code' ] ) ; // HTTP headers foreach ( $ httpHeaders as $ k => $ v ) { $ response -> header ( $ k , $ v ) ; } $ response -> header ( 'Content-Type' , 'application/json' ) -> setEtag ( md5 ( json_encode ( $ data ) ) ) ; return $ response ; }
Format a json Response.

@param mixed $data        The data to format into JSON
@param array $headers     Headers to set into the JSON output
@param array $httpHeaders Http headers to insert into the Response

@return Response
Format a json Response .