配置文件 也使用了copyrequestbody = true
使用postman http://192.168.20.221:8090/json?id=1&name="demo" 模拟,得到结果是
后端实现代码:
```go
type Myuse struct {
Id int64 `orm:"auto" json:"id" `
Name string `orm:"size(100)" json:"name" `
}
type Mread struct {
beego.Controller
}
func (c *Mread) Get() {
mys := models.DataListJson()
c.Data["json"] = &mys
c.ServeJSON()
}
func (c *Mread) Post() {
var myuse Myuse
json.Unmarshal(c.Ctx.Input.RequestBody,&myuse)
c.Data["json"] = &myuse
c.ServeJSON()
}
```
postman返回结果
{
"id": 0,
"name": ""
}