当前位置:网站首页>golang json returns null
golang json returns null
2022-08-01 17:34: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"
}
边栏推荐
猜你喜欢
随机推荐
金仓数据库 OCCI迁移指南(3. KingbaseES的OCCI特性支持)
2022.08月--pushmall推贴共享电商更新与开发计划
SQL窗口函数
ROS2系列知识(6):Action服务概念
SQL函数 TO_CHAR(二)
XAML WPF项目groupBox控件
MySQL's maximum recommended number of rows is 2000w, is it reliable?
使用设备树时对应的驱动编程
基于BiGRU和GAN的数据生成方法
B005 – 基于STC8的单片机智能路灯控制系统
金仓数据库KingbaseES安全指南--6.9. Ident身份验证
FTP helper class for C#
力扣每日一题-第45天-697. 数组的度
主流小程序框架性能分析
11 Publish a series as soon as it is released
sql添加索引
吴恩达机器学习课后习题——kmeans
Complete knapsack problem to find the number of combinations and permutations
今年最火爆的词:商业分析,看这一篇就够了!
Detailed explanation of the working principle of crystal oscillator









