The code would benefit a lot from a metadata structure that defines exactly what ruller-dsl expects from a json rule. With the usage of Go's json annotations, a good part of the parsing logic can be removed.
Proposal:
type RuleGroup struct {
Label string `json:"label,omitempty"`
Config Config `json:"_config"`
Groups map[string]interface{} `json:"_groups"`
Items []Item `json:"_items"`
}
type Config struct {
Seed int `json:"seed"`
DefaultCondition interface{} `json:"default_condition,omitempty"`
}
type Item struct {
Label string `json:"label"`
Items []Item `json:"label"`
Custom map[string]interface{} `json:"-"` // unkown fields should go here
Condition string `json:"_condition"`
}
The code would benefit a lot from a metadata structure that defines exactly what ruller-dsl expects from a json rule. With the usage of Go's json annotations, a good part of the parsing logic can be removed.
Proposal: