-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.go
29 lines (25 loc) · 984 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package jsonpath
// Config represents the configuration parameters.
type Config struct {
filterFunctions map[string]func(interface{}) (interface{}, error)
aggregateFunctions map[string]func([]interface{}) (interface{}, error)
accessorMode bool
}
// SetFilterFunction sets the custom function.
func (c *Config) SetFilterFunction(id string, function func(interface{}) (interface{}, error)) {
if c.filterFunctions == nil {
c.filterFunctions = map[string]func(interface{}) (interface{}, error){}
}
c.filterFunctions[id] = function
}
// SetAggregateFunction sets the custom function.
func (c *Config) SetAggregateFunction(id string, function func([]interface{}) (interface{}, error)) {
if c.aggregateFunctions == nil {
c.aggregateFunctions = map[string]func([]interface{}) (interface{}, error){}
}
c.aggregateFunctions[id] = function
}
// SetAccessorMode sets a collection of accessors to the result.
func (c *Config) SetAccessorMode() {
c.accessorMode = true
}