How to create a language with nested parameter support?
pmalekn opened this issue · 2 comments
pmalekn commented
I need to create a language with some concrete set of rules (to obtain an ES query). I already have something like:
func getLanguage() gval.Language {
return gval.NewLanguage(
gval.InfixTextOperator("==", eqStringOp),
gval.InfixOperator("&&", andOp),
gval.InfixOperator("||", orOp),
gval.Base(),
)
}
and I evaluate it with:
var paramMap = map[string]string{
"device": "device_id",
"type": "type",
"label.id": "label.id",
"label.value": "label.value",
}
result, err := lang.Evaluate(`label.id = "my-id"`, paramMap)
How can I add nested parameter support (as it is support when calling gval.Evaluate()
)?
generikvault commented
use nested maps
var paramMap = map[string]string{
"device": "device_id",
"type": "type",
"label": map[string]string{
"id": "label.id",
"value": "label.value",
},
}
pmalekn commented
Thanks! I somehow also figured it out after some digging!