Returns response object with body in json format. Args: body (Any): Response data to be serialized. status (int, optional): HTTP response code. Defaults to `200`. headers (Dict[str, str], optional): Custom HTTP headers. Defaults to `None`. content_type (str, opti
(
body: Any,
status: int = 200,
headers: dict[str, str] | None = None,
content_type: str = "application/json",
dumps: Callable[..., AnyStr] | None = None,
**kwargs: Any,
)
| 34 | |
| 35 | |
| 36 | def json( |
| 37 | body: Any, |
| 38 | status: int = 200, |
| 39 | headers: dict[str, str] | None = None, |
| 40 | content_type: str = "application/json", |
| 41 | dumps: Callable[..., AnyStr] | None = None, |
| 42 | **kwargs: Any, |
| 43 | ) -> JSONResponse: |
| 44 | """Returns response object with body in json format. |
| 45 | |
| 46 | Args: |
| 47 | body (Any): Response data to be serialized. |
| 48 | status (int, optional): HTTP response code. Defaults to `200`. |
| 49 | headers (Dict[str, str], optional): Custom HTTP headers. Defaults to `None`. |
| 50 | content_type (str, optional): The content type (string) of the response. Defaults to `"application/json"`. |
| 51 | dumps (Callable[..., AnyStr], optional): A custom json dumps function. Defaults to `None`. |
| 52 | **kwargs (Any): Remaining arguments that are passed to the json encoder. |
| 53 | |
| 54 | Returns: |
| 55 | JSONResponse: A response object with body in json format. |
| 56 | """ # noqa: E501 |
| 57 | return JSONResponse( |
| 58 | body, |
| 59 | status=status, |
| 60 | headers=headers, |
| 61 | content_type=content_type, |
| 62 | dumps=dumps, |
| 63 | **kwargs, |
| 64 | ) |
| 65 | |
| 66 | |
| 67 | def text( |
searching dependent graphs…