mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
write dynamic categories into feed categories document.
This commit is contained in:
parent
72a7240fd0
commit
198e5b8897
4 changed files with 122 additions and 8 deletions
20
util/json.go
20
util/json.go
|
|
@ -146,3 +146,23 @@ func (pe *PathEval) Match(matcher []PathEvalMatcher, doc interface{}) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Strings searches the given document for the given set of expressions
|
||||
// and returns the corresponding strings. The optional flag indicates
|
||||
// if the expression evaluation have to succseed or not.
|
||||
func (pe *PathEval) Strings(
|
||||
exprs []string,
|
||||
optional bool,
|
||||
doc interface{},
|
||||
) ([]string, error) {
|
||||
results := make([]string, 0, len(exprs))
|
||||
var result string
|
||||
matcher := StringMatcher(&result)
|
||||
for _, expr := range exprs {
|
||||
if err := pe.Extract(expr, matcher, optional, doc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
results = append(results, result)
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue