Skip to content

Commit 8ebb15e

Browse files
committed
更新文档,修正使用操作
1 parent 34402c7 commit 8ebb15e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ func main() {
724724
fmt.Println(string(articleBytes)) //以下是通过json-filter 过滤后的json,此输出是article接口下的json
725725
//{"avatar":"avatar","nickname":"boyan","uid":1}
726726

727-
//filter.SelectMarshal 是一个方便测试查看的方法,先过滤,然后再编码成json字符串返回,有错误直接panic,三部操作一气呵成,适合测试查看等
727+
//filter.SelectMarshal.MustJSON() 是一个方便测试查看的方法,先过滤,然后再编码成json字符串返回,有错误直接panic,三部操作一气呵成,适合测试查看等
728728
//下面为了方便演示,将使用SelectMarshal api来进行
729729
fmt.Println(filter.SelectMarshal("article", user).MustJSON()) //以下是通过json-filter 过滤后的json,此输出是article接口下的json
730730
//{"avatar":"avatar","nickname":"boyan","uid":1}
@@ -1159,12 +1159,12 @@ type User struct {
11591159

11601160
func (u User) ArticleResp() interface{} {
11611161
//这样当你后面想要优化性能时可以在这里进行优化,
1162-
return filter.SelectMarshal("article",u).Interface()
1162+
return filter.Select("article",u)
11631163
}
11641164

11651165
func (u User) ProfileResp() interface{} {
11661166
//这样当你后面想要优化性能时可以在这里进行优化,
1167-
return filter.SelectMarshal("profile",u).Interface()
1167+
return filter.Select("profile",u)
11681168
}
11691169

11701170
func (u User) ChatResp() interface{} {
@@ -1194,7 +1194,7 @@ type User struct {
11941194
}
11951195

11961196
func (u User) FilterProfile() interface{} {
1197-
return filter.SelectMarshal("profile", u).Interface()
1197+
return filter.Select("profile", u)
11981198
}
11991199

12001200
func main() {
@@ -1253,7 +1253,7 @@ func UserRes(c *gin.Context) {
12531253
Avatar: "avatar",
12541254
}
12551255

1256-
OkWithData(filter.SelectMarshal("profile", user).Interface(), c)
1256+
OkWithData(filter.Select("profile", user), c)
12571257
}
12581258
```
12591259

0 commit comments

Comments
 (0)