github.com/crowdsecurity/crowdsec@v1.6.1/pkg/parser/enrich_unmarshal.go (about)

     1  package parser
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	log "github.com/sirupsen/logrus"
     7  
     8  	"github.com/crowdsecurity/crowdsec/pkg/types"
     9  )
    10  
    11  func unmarshalJSON(field string, p *types.Event, ctx interface{}, plog *log.Entry) (map[string]string, error) {
    12  	err := json.Unmarshal([]byte(p.Line.Raw), &p.Unmarshaled)
    13  	if err != nil {
    14  		plog.Errorf("could not unmarshal JSON: %s", err)
    15  		return nil, err
    16  	}
    17  	plog.Tracef("unmarshaled JSON: %+v", p.Unmarshaled)
    18  	return nil, nil
    19  }
    20  
    21  func unmarshalInit(cfg map[string]string) (interface{}, error) {
    22  	return nil, nil
    23  }