当前位置:网站首页>golang json 返回空值
golang json 返回空值
2022-08-01 17:33:00 【dorlolo】
使用struct{}{}
返回空对象
func OkReply(c *app.RequestContext) {
c.JSON(200, CommonResult{
Data: struct{
}{
},
Code: ErrCode_None,
Message: "ok",
})
}
返回json
{
"data":{
},
"code":0,
"message":"ok"
}
使用make([]interface{}, 0)
返回空数组
func OkReply(c *app.RequestContext) {
c.JSON(200, CommonListResult{
List: make([]interface{
}, 0),
Code: ErrCode_None,
Message: "ok",
})
}
返回json
{
"data":[],
"code":0,
"message":"ok"
}
边栏推荐
猜你喜欢
随机推荐
在码云拉取代码后,调整了seata版本1.5.2。出现如下异常。是因为数据库表缺少字段导致的吗?
移动端吸顶方案
JumpServer堡垒机部署
SRM供应商管理系统如何助力口腔护理企业实现采购战略的转型升级
SQL函数 TO_CHAR(三)
The anxiety of the post-90s was cured by the vegetable market
2022强网杯CTF---强网先锋 ASR wp
半自动化爬虫-爬取一个网站的内容及回复
助推科技强国高质量发展《科创超级训练营》系列活动正式拉开帷幕
06 redis cluster structures
04 flink 集群搭建
hcip第九天
使用设备树时对应的驱动编程
Xingtu has been short of disruptive products?Will this M38T from the Qingdao factory be a breakthrough?
C#的CSV格式文件帮助类
网上开户佣金万一靠谱吗,网上开户安全吗
力扣每日一题-第45天-697. 数组的度
Winform的消息提示框帮助类
Are online account opening commissions reliable? Is online account opening safe?
11 一发布就发布一系列系列