package server import ( "encoding/json" "github.com/Neur0toxine/sshpoke/pkg/dto" ) type Connections map[string]dto.Container func (c Connections) MarshalJSON() ([]byte, error) { items := []dto.Container{} for _, item := range c { items = append(items, item) } return json.Marshal(items) } func (c *Connections) UnmarshalJSON(data []byte) error { var items []dto.Container if err := json.Unmarshal(data, &items); err != nil { return err } m := make(map[string]dto.Container, len(items)) for _, item := range items { m[item.ID] = item } *c = m return nil }