> For the complete documentation index, see [llms.txt](https://meetbill.gitbook.io/butterfly-project-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://meetbill.gitbook.io/butterfly-project-doc/project-framework/how/api/funcattr/butterfly-json.md).

# (1) json

@funcattr.api 标识此函数是用于 json 处理

> * request：如下方法都会转为 `{"str_info": "hello_world"}` 进行传参到 handler, 即 `ret = handler(**params)`
>   * GET 方法: `str_info=hello_world`
>   * POST 方法: `{"str_info": "hello_world"}`
> * response: 状态信息字段，数据信息字段，自定义 HTTP 报文头信息列表
>   * 返回 `retstat.OK, {"str_info": str_info}` 时，实际返回到客户端的时候是以 `("Content-Type", "application/json")` 方式返回 `{"stat": "OK", "str_info": str_info}`

```
@funcattr.api
def hello(req, str_info):
    """
    带参数请求例子

    Args:
        req     : Request
        str_info: (str)
    Returns:
        json_status, Content, headers
    """
    isinstance(req, Request)
    return retstat.OK, {"str_info": str_info}, [(__info, __version)]
```
