diff --git a/apis/v1beta1/config.go b/apis/v1beta1/config.go index 61fecb3ad1..4eab8d485d 100644 --- a/apis/v1beta1/config.go +++ b/apis/v1beta1/config.go @@ -90,7 +90,22 @@ func (c *AnyConfig) MarshalJSON() ([]byte, error) { if c == nil { return []byte("{}"), nil } - return json.Marshal(c.Object) + return json.Marshal(c.convertNilToEmptyMap(c.Object)) +} + +func (c *AnyConfig) convertNilToEmptyMap(m map[string]interface{}) map[string]interface{} { + result := make(map[string]interface{}) + for k, v := range m { + switch val := v.(type) { + case nil: + result[k] = map[string]interface{}{} + case map[string]interface{}: + result[k] = c.convertNilToEmptyMap(val) + default: + result[k] = v + } + } + return result } // Pipeline is a struct of component type to a list of component IDs.