fix the behavior of json unmarshal to not return the full map (#2199)
This commit is contained in:
parent
8aca0ea860
commit
77f2968267
2 changed files with 8 additions and 5 deletions
|
@ -175,8 +175,8 @@ func UnmarshalJSON(params ...any) (any, error) {
|
|||
err := json.Unmarshal([]byte(jsonBlob), &out)
|
||||
if err != nil {
|
||||
log.Errorf("UnmarshalJSON : %s", err)
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
target[key] = out
|
||||
return target, nil
|
||||
return "", nil
|
||||
}
|
||||
|
|
|
@ -133,11 +133,11 @@ func (n *Node) ProcessStatics(statics []types.ExtraField, event *types.Event) er
|
|||
case int:
|
||||
value = strconv.Itoa(out)
|
||||
case map[string]interface{}:
|
||||
clog.Warnf("Expression returned a map, please use ToJsonString() to convert it to string if you want to keep it as is, or refine your expression to extract a string")
|
||||
clog.Warnf("Expression '%s' returned a map, please use ToJsonString() to convert it to string if you want to keep it as is, or refine your expression to extract a string", static.ExpValue)
|
||||
case []interface{}:
|
||||
clog.Warnf("Expression returned a map, please use ToJsonString() to convert it to string if you want to keep it as is, or refine your expression to extract a string")
|
||||
clog.Warnf("Expression '%s' returned an array, please use ToJsonString() to convert it to string if you want to keep it as is, or refine your expression to extract a string", static.ExpValue)
|
||||
case nil:
|
||||
clog.Debugf("Expression returned nil, skipping")
|
||||
clog.Debugf("Expression '%s' returned nil, skipping", static.ExpValue)
|
||||
default:
|
||||
clog.Errorf("unexpected return type for RunTimeValue : %T", output)
|
||||
return errors.New("unexpected return type for RunTimeValue")
|
||||
|
@ -265,6 +265,9 @@ func Parse(ctx UnixParserCtx, xp types.Event, nodes []Node) (types.Event, error)
|
|||
if event.Meta == nil {
|
||||
event.Meta = make(map[string]string)
|
||||
}
|
||||
if event.Unmarshaled == nil {
|
||||
event.Unmarshaled = make(map[string]interface{})
|
||||
}
|
||||
if event.Type == types.LOG {
|
||||
log.Tracef("INPUT '%s'", event.Line.Raw)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue