Comments (7)
您好,现在新增了func选择器,可以实现您的需求,最新版本v1.8已经添加该功能,如果您用得上的话可以尝试一下,
具体用法
package main
import (
"fmt"
"github.com/liu-cn/json-filter/filter"
)
type People struct {
NO int json:"no"
Name string json:"name,select(log)"
IDCardNO string json:"id_card_no,,select(log),func(GetHideID)"
}
func (p People) GetHideID() string {
return "*****"
}
var people = People{
NO: 1,
Name: "张三",
IDCardNO: "441400202211241234",
}
func filterPeople() {
fmt.Println(filter.Select("log", &people))
//{"id_card_no":"*****","name":"张三"}
fmt.Println(people.IDCardNO)
//441400202211241234
}
from json-filter.
您好,可以详细描述一下您的需求和功能吗?比如这个自动进行脱敏返回是具体是什么意思,需要您结合业务场景详细的描述一下,谢谢。
from json-filter.
比如有一个结构体:
type People struct {
NO int
Name string
IDCardNO string
}
var people = People{
NO: 1,
Name: "张三",
IDCardNO: "441400202211241234",
}
// to json: {NO:1, Name:"张三", IDCardNO:"******"}
要输出脱敏的字段是因为在记录日志的时候,身份证号作为敏感信息是不能记录的,但是如果IDCardNO不输出的话,又会被错误认为是没有这个值({NO:1, Name:"张三"})
from json-filter.
抱歉此项目仅仅对字段进行过滤,你提的需求不是普遍需求,所以还是建议您在打印日志前自己手动复制一个结构体把敏感字段信息给处理掉,再过滤。
from json-filter.
不是普遍需求
from json-filter.
from json-filter.
如果用的话,建议您看一下这个文件,https://github.com/liu-cn/json-filter/blob/main/example/func_test.go
上面用法写的很详细
from json-filter.
Related Issues (9)
- 您好楼主,请教一个问题 HOT 4
- 微信技术交流群 HOT 1
- 性能优化方案
- 编码算法
- 你好,作者,我对序列化这里有一个问题请教 HOT 7
- 自定义类型失效 HOT 3
- 定义baseModel的时候不生效 HOT 16
- uuid.UUID和[]byte类型被转成了json数组 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-filter.