diff --git a/pkg/interceptors/cel/cel_test.go b/pkg/interceptors/cel/cel_test.go index 8a57d099a..47960ca08 100644 --- a/pkg/interceptors/cel/cel_test.go +++ b/pkg/interceptors/cel/cel_test.go @@ -433,6 +433,13 @@ func TestExpressionEvaluation(t *testing.T) { "jsonArray": []string{ "one", "two", }, + "jsonObjects": []map[string]interface{}{ + { + "testing1": map[string]interface{}{ + "testing": []string{"test1", "test2"}, + }, + }, + }, } refParts := strings.Split(testRef, "/") @@ -589,6 +596,11 @@ func TestExpressionEvaluation(t *testing.T) { expr: "body.jsonArray.marshalJSON()", want: types.String(`["one","two"]`), }, + { + name: "marshal JSON objects to string", + expr: "body.jsonObjects.marshalJSON()", + want: types.String(`[{"testing1":{"testing":["test1","test2"]}}]`), + }, { name: "extension base64 decoding", expr: "base64.decode(body.b64value)", diff --git a/pkg/interceptors/cel/triggers.go b/pkg/interceptors/cel/triggers.go index 94b734f96..f1d95fd91 100644 --- a/pkg/interceptors/cel/triggers.go +++ b/pkg/interceptors/cel/triggers.go @@ -157,7 +157,7 @@ type triggersLib struct { func (t triggersLib) CompileOptions() []cel.EnvOption { mapStrDyn := cel.MapType(cel.StringType, cel.DynType) - listStrDyn := cel.ListType(cel.StringType) + listStrDyn := cel.ListType(cel.DynType) return []cel.EnvOption{ cel.Function("match", cel.MemberOverload("match_map_string_string", []*cel.Type{mapStrDyn, cel.StringType, cel.StringType}, cel.BoolType,