IJsonRead支持Value, 泛读取数据
This commit is contained in:
22
filter.go
22
filter.go
@ -10,6 +10,8 @@ package filter
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.zhangdeman.cn/zhangdeman/json_filter/abstract"
|
||||
"git.zhangdeman.cn/zhangdeman/json_filter/implement"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
@ -21,6 +23,22 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
func NewFilterWithJson(sourceData string, filterRuleList []MapRule, jsonRead abstract.IJsonRead, jsonWrite abstract.IJsonWrite) *filter {
|
||||
if nil == jsonRead {
|
||||
jsonRead = implement.NewGjsonRead(sourceData)
|
||||
}
|
||||
if nil == jsonWrite {
|
||||
jsonWrite = implement.NewSjsonWrite()
|
||||
}
|
||||
return &filter{
|
||||
jsonRaad: jsonRead,
|
||||
jsonWrite: jsonWrite,
|
||||
sourceData: sourceData,
|
||||
formatResult: "",
|
||||
filterRuleList: filterRuleList,
|
||||
}
|
||||
}
|
||||
|
||||
// NewFilter 过滤器实例
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
@ -30,6 +48,8 @@ func NewFilter(sourceData string, filterRuleList []MapRule) *filter {
|
||||
return &filter{
|
||||
sourceData: sourceData,
|
||||
formatResult: "{}",
|
||||
jsonRaad: implement.NewGjsonRead(sourceData),
|
||||
jsonWrite: implement.NewSjsonWrite(),
|
||||
filterRuleList: filterRuleList,
|
||||
}
|
||||
}
|
||||
@ -40,6 +60,8 @@ func NewFilter(sourceData string, filterRuleList []MapRule) *filter {
|
||||
//
|
||||
// Date : 11:58 2022/7/4
|
||||
type filter struct {
|
||||
jsonRaad abstract.IJsonRead
|
||||
jsonWrite abstract.IJsonWrite
|
||||
sourceData string
|
||||
formatResult string
|
||||
filterRuleList []MapRule
|
||||
|
||||
Reference in New Issue
Block a user