protected function getRequestJson()
    {
        if ($this->request->getContentType() !== 'json') {
            throw new UserMessageException(t('Invalid request Content-Type: %s', $this->request->headers->get('Content-Type', '')), Response::HTTP_NOT_ACCEPTABLE);
        }
        $contentBody = $this->request->getContent();
        $contentJson = @json_decode($contentBody, true);
        if (!is_array($contentJson)) {
            throw new UserMessageException(t('Failed to parse the request body as JSON'), Response::HTTP_NOT_ACCEPTABLE);
        }

        return $contentJson;
    }
protected function getRequestJson()
    {
        if ($this->request->getContentType() !== 'json') {
            throw new UserMessageException(t('Invalid request Content-Type: %s', $this->request->headers->get('Content-Type', '')), Response::HTTP_NOT_ACCEPTABLE);
        }
        $contentBody = $this->request->getContent();
        $contentJson = @json_decode($contentBody, true);
        if (!is_array($contentJson)) {
            throw new UserMessageException(t('Failed to parse the request body as JSON'), Response::HTTP_NOT_ACCEPTABLE);
        }

        return $contentJson;
    }
protected function getRequestJson ( ) { if ( $ this -> request -> getContentType ( ) !== 'json' ) { throw new UserMessageException ( t ( 'Invalid request Content-Type: %s' , $ this -> request -> headers -> get ( 'Content-Type' , '' ) ) , Response :: HTTP_NOT_ACCEPTABLE ) ; } $ contentBody = $ this -> request -> getContent ( ) ; $ contentJson = @ json_decode ( $ contentBody , true ) ; if ( ! is_array ( $ contentJson ) ) { throw new UserMessageException ( t ( 'Failed to parse the request body as JSON' ) , Response :: HTTP_NOT_ACCEPTABLE ) ; } return $ contentJson ; }
Check if the request is a JSON request and returns the posted parameters.

@throws UserMessageException

@return array
Check if the request is a JSON request and returns the posted parameters .