public function getJsonBody($assoc = true) { $r = json_decode(file_get_contents('php://input'), $assoc); if ($r === null) { throw new RequestException('json_decode raw body failed.'); } return $r; }