Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rule ¶
type Rule struct {
RemoveProperties []string `json:"remove_properties"`
PropertySimplifiers map[string]*Rule `json:"property_simplifiers"`
}
Rule defines the rule structure for property removal and nested property rules.
type Simplifier ¶
type Simplifier interface {
// Simplify method:
// 1. Receives any type of struct or pointer to it, returns the same type of struct(pointer)
// 2. Will not modify the original, but just make a copy as the return value
// 3. Removes the properties of the return value according to the rules
Simplify(original interface{}) (interface{}, error)
}
Simplifier defines the interface for struct simplification.
func ExtendSimplifier ¶
func ExtendSimplifier(base Simplifier, rulesJson string) (Simplifier, error)
ExtendSimplifier extends the base simplifier with the given rules. The new Simplifier will have the rules merge from the base and the given rules.
func ExtendSimplifierByRule ¶
func ExtendSimplifierByRule(baseImpl *simplifierImpl, newRule *Rule) (Simplifier, error)
func NewSimplifier ¶
func NewSimplifier(rulesJson string) (Simplifier, error)
NewSimplifier creates a new instance of simplifierImpl with the given rules
Example:
{
"remove_properties": [ "field1"],
"property_simplifiers": {
"field2": {
"remove_properties": [ "sub2" ]
"property_simplifiers": {
"sub1": {
"remove_properties": [ "a", "b" ]
}
}
}
}
}
For struct instance root:
var root ExampleStruct
The following properties will be removed:
root.field1 root.field2.sub2 root.field2.sub1.a root.field2.sub1.b
Other properties will be kept.
func NewSimplifierByRule ¶
func NewSimplifierByRule(rule *Rule) (Simplifier, error)
Click to show internal directories.
Click to hide internal directories.