Skip to content

Commit 65528e9

Browse files
authored
Update go-tips.cn.md
1 parent 0f06ba2 commit 65528e9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

go-tips.cn.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ json.Marshal(struct{
119119
```
120120

121121
# 用字符串传递数字
122+
123+
```golang
124+
type TestObject struct {
125+
Field1 int `json:",string"`
126+
}
127+
```
128+
129+
这个对应的json是 `{"Field1": "100"}`
130+
131+
如果json是 `{"Field1": 100}` 则会报错
132+
122133
# 容忍字符串和数字互转
123134
# 容忍空数组作为对象
124135
# 使用 MarshalJSON支持time.Time

0 commit comments

Comments
 (0)