crowdsec/pkg/parser/enrich_unmarshal.go
mmetc b9a3acb03f
light pkg/parser cleanup (#2279)
* pkg/parser: clean up imports
* remove duplicate import
* simplify boolean expression
* don't check length before range
* if..else if.. -> switch/case
* errors.Wrap -> fmt.Errorf
* typo, lint
* redundant break
2023-06-13 13:16:13 +02:00

23 lines
545 B
Go

package parser
import (
"encoding/json"
log "github.com/sirupsen/logrus"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
func unmarshalJSON(field string, p *types.Event, ctx interface{}, plog *log.Entry) (map[string]string, error) {
err := json.Unmarshal([]byte(p.Line.Raw), &p.Unmarshaled)
if err != nil {
plog.Errorf("could not unmarshal JSON: %s", err)
return nil, err
}
plog.Tracef("unmarshaled JSON: %+v", p.Unmarshaled)
return nil, nil
}
func unmarshalInit(cfg map[string]string) (interface{}, error) {
return nil, nil
}