Skip to content

Commit 140f4dc

Browse files
committed
update:readme 更新文档,零值忽略
1 parent f4d7aa4 commit 140f4dc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,16 @@ omit则反之,标记的字段会被排除。
144144
f:=filter.OmitMarshal("chat",el) //这时Nickname字段就被排除掉了。
145145
```
146146

147-
##### omitempty为空忽略
147+
##### omitempty零值忽略
148148

149-
支持空值忽略,omitempty必须写在结构体字段标签名字后面
150-
151-
仅支持nil类型。比如以下会在article或者profile接口Nickname为nil时直接忽略该字段。
149+
支持零值忽略,omitempty必须写在结构体字段标签名字后面
152150

153151
```go
154-
Nickname *string `json:"nickname,omitempty,select(article|profile)"`
152+
Nickname *string `json:"nickname,omitempty,select(article|profile)"` //为nil忽略
153+
Nickname string `json:"nickname,omitempty,select(article|profile)"` //为“”忽略
154+
Age int `json:"age,omitempty,select(article|profile)"` //为0忽略
155+
156+
//空结构体也可以忽略
155157
```
156158

157159

0 commit comments

Comments
 (0)