当前位置:网站首页>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))
}
边栏推荐
- 老掉牙的 synchronized 锁优化,一次给你讲清楚!
- Dede plug-in (multi-function integration)
- Global and Chinese PCB function test scale analysis and development prospect planning report Ⓑ 2022 ~ 2027
- Awk from entry to penetration (6) regular matching
- Global and Chinese market of planar waveguide optical splitter 2022-2028: Research Report on technology, participants, trends, market size and share
- Talk about single case mode
- Research Report on the current market situation and development prospects of calcium sulfate whiskers in China (2022 Edition)
- Target detection -- intensive reading of yolov3 paper
- What is inner connection and outer connection? What are the uses and benefits
- Simulate EF dbcontext with MOQ - mocking EF dbcontext with MOQ
猜你喜欢

Ehrlich sieve + Euler sieve + interval sieve
![C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)](/img/dc/5c8077c10cdc7ad6e6f92dedfbe797.png)
C language - Introduction - Foundation - syntax - [variable, constant light, scope] (V)

How does idea withdraw code from remote push

If you can quickly generate a dictionary from two lists

Educational Codeforces Round 119 (Rated for Div. 2)

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

Mantis creates users without password options

2022-2028 global small batch batch batch furnace industry research and trend analysis report

Mac platform forgets the root password of MySQL

2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report
随机推荐
awk从入门到入土(8)数组
Analysis report on the production and marketing demand and investment forecast of tellurium dioxide in the world and China Ⓣ 2022 ~ 2027
Awk from entry to earth (8) array
什么是uid?什么是Auth?什么是验证器?
How does idea withdraw code from remote push
Global and Chinese markets for laser assisted liposuction (LAL) devices 2022-2028: Research Report on technology, participants, trends, market size and share
After unplugging the network cable, does the original TCP connection still exist?
You can see the employment prospects of PMP project management
Solve the problem of "Chinese garbled MySQL fields"
Development trend and market demand analysis report of high purity tin chloride in the world and China Ⓔ 2022 ~ 2027
Awk from entry to soil (5) simple condition matching
HMS core helps baby bus show high-quality children's digital content to global developers
C language - Introduction - Foundation - syntax - [operators, type conversion] (6)
C language - Introduction - Foundation - syntax - [identifier, keyword, semicolon, space, comment, input and output] (III)
The 14th five year plan and investment risk analysis report of China's hydrogen fluoride industry 2022 ~ 2028
Function comparison between cs5261 and ag9310 demoboard test board | cost advantage of cs5261 replacing ange ag9310
C language - Introduction - Foundation - syntax - [main function, header file] (II)
awk从入门到入土(6)正则匹配
In depth investigation and Strategic Research Report on China's motion controller Market (2022 Edition)
How to pass custom object via intent in kotlin