src/Keboola/Syrup/Controller/BaseController.php
protected function getPostJson(Request $request, $assoc = true)
    {
        $return = array();
        $body = $request->getContent();

        if (!empty($body) && !is_null($body) && $body != 'null') {
            $return = json_decode($body, $assoc);
            if (json_last_error() != JSON_ERROR_NONE) {
                throw new UserException("Bad JSON format of request body: " . json_last_error_msg());
            }
        }

        return $return;
    }
protected function getPostJson(Request $request, $assoc = true)
    {
        $return = array();
        $body = $request->getContent();

        if (!empty($body) && !is_null($body) && $body != 'null') {
            $return = json_decode($body, $assoc);
            if (json_last_error() != JSON_ERROR_NONE) {
                throw new UserException("Bad JSON format of request body: " . json_last_error_msg());
            }
        }

        return $return;
    }
protected function getPostJson ( Request $ request , $ assoc = true ) { $ return = array ( ) ; $ body = $ request -> getContent ( ) ; if ( ! empty ( $ body ) && ! is_null ( $ body ) && $ body != 'null' ) { $ return = json_decode ( $ body , $ assoc ) ; if ( json_last_error ( ) != JSON_ERROR_NONE ) { throw new UserException ( "Bad JSON format of request body: " . json_last_error_msg ( ) ) ; } } return $ return ; }
Extracts POST data in JSON from request
@param Request $request
@param bool $assoc
@return array|mixed
Extracts POST data in JSON from request