当前位置:网站首页>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))
}
边栏推荐
- Codeforces Round #803 (Div. 2)(A-D)
- Global and Chinese market of sampler 2022-2028: Research Report on technology, participants, trends, market size and share
- China battery grade manganese sulfate Market Forecast and strategic consulting report (2022 Edition)
- Some points needing attention in PMP learning
- After unplugging the network cable, does the original TCP connection still exist?
- Global and Chinese market of planar waveguide optical splitter 2022-2028: Research Report on technology, participants, trends, market size and share
- Investment analysis and prospect prediction report of global and Chinese high purity tin oxide Market Ⓞ 2022 ~ 2027
- Global and Chinese markets of water heaters in Saudi Arabia 2022-2028: Research Report on technology, participants, trends, market size and share
- C语言-入门-基础-语法-[主函数,头文件](二)
- Analysis report on the development status and investment planning of China's modular power supply industry Ⓠ 2022 ~ 2028
猜你喜欢

After unplugging the network cable, does the original TCP connection still exist?

How to batch change file extensions in win10

2022-2028 global seeder industry research and trend analysis report

You can see the employment prospects of PMP project management
![[C Advanced] file operation (2)](/img/50/e3f09d7025c14ee6c633732aa73cbf.jpg)
[C Advanced] file operation (2)
](/img/3f/4d8f4c77d9fde5dd3f53ef890ecfa8.png)
C語言-入門-基礎-語法-[運算符,類型轉換](六)

Sequence model

2022-2028 global protein confectionery industry research and trend analysis report

If you can quickly generate a dictionary from two lists

At the age of 30, I changed to Hongmeng with a high salary because I did these three things
随机推荐
地平线 旭日X3 PI (一)首次开机细节
Tkinter Huarong Road 4x4 tutorial II
Nurse level JDEC addition, deletion, modification and inspection exercise
awk从入门到入土(12)awk也可以写脚本,替代shell
Explain TCP protocol in detail three handshakes and four waves
2022-2028 global strain gauge pressure sensor industry research and trend analysis report
Service call feign of "micro service"
Multilingual Wikipedia website source code development part II
How to pass custom object via intent in kotlin
If you can quickly generate a dictionary from two lists
Jianzhi offer 09 realizes queue with two stacks
20220701 Barbalat引理证明
Investment analysis and future production and marketing demand forecast report of China's paper industry Ⓥ 2022 ~ 2028
What is uid? What is auth? What is a verifier?
Trim leading or trailing characters from strings- Trim leading or trailing characters from a string?
"How to connect the network" reading notes - Web server request and response (4)
UML 时序图[通俗易懂]
Ehrlich sieve + Euler sieve + interval sieve
How to write unit test cases
Use Alibaba cloud NPM image acceleration