当前位置:网站首页>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特性支持)
- UI helper class for Winform - some components will use DevExpress components
- 关系运算符和if,else语句
- 银行案例|Zabbix跨版本升级指南,4.2-6.0不香吗?
- 访问域名直接访问wordpress
- 2022年SQL经典面试题总结(带解析)
- 2022.08月--pushmall推贴共享电商更新与开发计划
- GridControl helper class for DevExpress
猜你喜欢

Xingtu has been short of disruptive products?Will this M38T from the Qingdao factory be a breakthrough?

C语言理论--笔试面试基础稳固

频域分析实践介绍

SRM供应商管理系统如何助力口腔护理企业实现采购战略的转型升级

关于Mysql服务无法启动的问题

移动端吸顶方案

金仓数据库KingbaseES安全指南--6.3. Kerberos身份验证

The anxiety of the post-90s was cured by the vegetable market

下载 | 谷歌科学家Kevin P. Murphy发布新书《概率机器学习:高级主题》

C语言:表达式求值详解
随机推荐
极化微波成像概述3
GRUB2的零日漏洞补丁现已推出
创造建材数字转型新视界,中建材如何多边赋能集团业务快速发展
When custom annotations implement log printing, specific fields are blocked from printing
Ali's official Redis development specification
助推科技强国高质量发展《科创超级训练营》系列活动正式拉开帷幕
gtk显示4通道rgba图像
B001 - 基于STM32的智能生态鱼缸
主流小程序框架性能分析
浅谈大数据背景下数据库安全保障体系
Are online account opening commissions reliable? Is online account opening safe?
B005 – 基于STC8的单片机智能路灯控制系统
2022.08月--pushmall推贴共享电商更新与开发计划
插入排序 优化插入排序
How can become a good architect necessary skills: painting for all the people praise the system architecture diagram?What is the secret?Quick to open this article and have a look!.
深入分析类加载器
存储日报-数据湖架构权威指南(使用 Iceberg 和 MinIO)
金仓数据库 KDTS 迁移工具使用指南(3. 系统部署)
SQL的substring_index()用法——MySQL字符串截取
M1芯片电脑安装cerebro