diff --git a/act/exprparser/functions.go b/act/exprparser/functions.go index 64103e07..37a38db5 100644 --- a/act/exprparser/functions.go +++ b/act/exprparser/functions.go @@ -151,7 +151,7 @@ func (impl *interperterImpl) join(array reflect.Value, sep reflect.Value) (strin func (impl *interperterImpl) toJSON(value reflect.Value) (string, error) { if value.Kind() == reflect.Invalid { - return "", nil + return "null", nil } json, err := json.MarshalIndent(value.Interface(), "", " ") diff --git a/act/exprparser/functions_test.go b/act/exprparser/functions_test.go index bdae533e..3c3d3477 100644 --- a/act/exprparser/functions_test.go +++ b/act/exprparser/functions_test.go @@ -137,6 +137,7 @@ func TestFunctionToJSON(t *testing.T) { name string }{ {"toJSON(env) }}", "{\n \"key\": \"value\"\n}", "toJSON"}, + {"toJSON(null)", "null", "toJSON-null"}, } env := &EvaluationEnvironment{