Giter Site home page Giter Site logo

Comments (7)

liu-cn avatar liu-cn commented on August 15, 2024 1

您好,现在新增了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.

liu-cn avatar liu-cn commented on August 15, 2024

您好,可以详细描述一下您的需求和功能吗?比如这个自动进行脱敏返回是具体是什么意思,需要您结合业务场景详细的描述一下,谢谢。

from json-filter.

zhangyongding avatar zhangyongding commented on August 15, 2024

比如有一个结构体:

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.

liu-cn avatar liu-cn commented on August 15, 2024

抱歉此项目仅仅对字段进行过滤,你提的需求不是普遍需求,所以还是建议您在打印日志前自己手动复制一个结构体把敏感字段信息给处理掉,再过滤。

from json-filter.

liu-cn avatar liu-cn commented on August 15, 2024

不是普遍需求

from json-filter.

liu-cn avatar liu-cn commented on August 15, 2024

image

from json-filter.

liu-cn avatar liu-cn commented on August 15, 2024

如果用的话,建议您看一下这个文件,https://github.com/liu-cn/json-filter/blob/main/example/func_test.go
上面用法写的很详细

from json-filter.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.