protected function createJsonResponse($data = null, $scope = null, $status = 200)
    {
        if ($data !== null) {
            $data = is_string($data) ?
                $data :
                $this->container->get('serializer')->serialize(
                    $data, 'json', empty($scope) ? array() : array('scope' => $scope)
                )
            ;
        }

        $response = new Response(null === $data ? '' : $data, $status);
        $response->headers->set('Content-Type', 'application/json');

        return $response;
    }
protected function createJsonResponse($data = null, $scope = null, $status = 200)
    {
        if ($data !== null) {
            $data = is_string($data) ?
                $data :
                $this->container->get('serializer')->serialize(
                    $data, 'json', empty($scope) ? array() : array('scope' => $scope)
                )
            ;
        }

        $response = new Response(null === $data ? '' : $data, $status);
        $response->headers->set('Content-Type', 'application/json');

        return $response;
    }
protected function createJsonResponse ( $ data = null , $ scope = null , $ status = 200 ) { if ( $ data !== null ) { $ data = is_string ( $ data ) ? $ data : $ this -> container -> get ( 'serializer' ) -> serialize ( $ data , 'json' , empty ( $ scope ) ? array ( ) : array ( 'scope' => $ scope ) ) ; } $ response = new Response ( null === $ data ? '' : $ data , $ status ) ; $ response -> headers -> set ( 'Content-Type' , 'application/json' ) ; return $ response ; }
Create a JsonResponse with given data, if object given, it will be serialize
with registered serializer.

@param mixed  $data
@param string $scope
@param int    $status

@return Response
Create a JsonResponse with given data if object given it will be serialize with registered serializer .