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;
    }