当前位置:网站首页>Solution to null JSON after serialization in golang
Solution to null JSON after serialization in golang
2022-07-04 09:16:00 【The diligent bird that flies first】
type animal struct {
name string
age int
}
func main(){
ani := animal{
name: "lcq",
age: 23,
}
marshal, err := json.Marshal(ani)
if err != nil {
fmt.Println("err:", err)
return
}
fmt.Println(string(marshal))
}
The serialized result is :
{
}
The main reason is that the attribute is lowercase , External packages cannot be accessed , Just change the field name to uppercase .
type animal struct {
Name string
Age int
}
func main(){
ani := animal{
Name: "lcq",
Age: 23,
}
marshal, err := json.Marshal(ani)
if err != nil {
fmt.Println("err:", err)
return
}
fmt.Println(string(marshal))
}
边栏推荐
- Explain TCP protocol in detail three handshakes and four waves
- LinkedList in the list set is stored in order
- Analysis report on the development status and investment planning of China's modular power supply industry Ⓠ 2022 ~ 2028
- Service call feign of "micro service"
- Global and Chinese markets of hemoglobin analyzers in care points 2022-2028: Research Report on technology, participants, trends, market size and share
- Leetcode topic [array] - 121 - the best time to buy and sell stocks
- How do microservices aggregate API documents? This wave of show~
- 2022-2028 global gasket plate heat exchanger industry research and trend analysis report
- 《网络是怎么样连接的》读书笔记 - FTTH
- 《网络是怎么样连接的》读书笔记 - Tcp/IP连接(二)
猜你喜欢
2022-2028 global visual quality analyzer industry research and trend analysis report
[error record] no matching function for call to 'cacheflush' cacheflush();)
How to ensure the uniqueness of ID in distributed environment
2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report
How does idea withdraw code from remote push
C language - Introduction - Foundation - syntax - [identifier, keyword, semicolon, space, comment, input and output] (III)
CLion-控制台输出中文乱码
Clion console output Chinese garbled code
Jianzhi offer 09 realizes queue with two stacks
C语言-入门-基础-语法-[主函数,头文件](二)
随机推荐
What is uid? What is auth? What is a verifier?
Markdown syntax
Flutter 小技巧之 ListView 和 PageView 的各种花式嵌套
什么是uid?什么是Auth?什么是验证器?
Target detection -- intensive reading of yolov3 paper
What exactly is DAAS data as a service? Don't be misled by other DAAS concepts
Analysis report on the development status and investment planning of China's modular power supply industry Ⓠ 2022 ~ 2028
In depth research and investment strategy report on China's hydraulic parts industry (2022 Edition)
Awk from entry to penetration (6) regular matching
Codeforces Round #793 (Div. 2)(A-D)
AI Winter Olympics | is the future coming? Enter the entrance of the meta universe - virtual digital human
Ehrlich sieve + Euler sieve + interval sieve
2022-2028 global edible probiotic raw material industry research and trend analysis report
2022-2028 global industry research and trend analysis report on anterior segment and fundus OTC detectors
Dede plug-in (multi-function integration)
The old-fashioned synchronized lock optimization will make it clear to you at once!
Report on research and investment prospect prediction of China's electronic grade sulfuric acid industry (2022 Edition)
《网络是怎么样连接的》读书笔记 - WEB服务端请求和响应(四)
awk从入门到入土(5)简单条件匹配
swatch