diff --git a/container/gmap/gmap_hash_any_any_map.go b/container/gmap/gmap_hash_any_any_map.go index c2006af43..28859ed45 100644 --- a/container/gmap/gmap_hash_any_any_map.go +++ b/container/gmap/gmap_hash_any_any_map.go @@ -457,6 +457,12 @@ func (m *AnyAnyMap) Merge(other *AnyAnyMap) { } } +// String returns the map as a string. +func (m *AnyAnyMap) String() string { + b, _ := m.MarshalJSON() + return gconv.UnsafeBytesToStr(b) +} + // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (m *AnyAnyMap) MarshalJSON() ([]byte, error) { return json.Marshal(gconv.Map(m.Map())) diff --git a/container/gmap/gmap_hash_int_any_map.go b/container/gmap/gmap_hash_int_any_map.go index 5cbbafe63..fa9541867 100644 --- a/container/gmap/gmap_hash_int_any_map.go +++ b/container/gmap/gmap_hash_int_any_map.go @@ -455,6 +455,12 @@ func (m *IntAnyMap) Merge(other *IntAnyMap) { } } +// String returns the map as a string. +func (m *IntAnyMap) String() string { + b, _ := m.MarshalJSON() + return gconv.UnsafeBytesToStr(b) +} + // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (m *IntAnyMap) MarshalJSON() ([]byte, error) { m.mu.RLock() diff --git a/container/gmap/gmap_hash_int_int_map.go b/container/gmap/gmap_hash_int_int_map.go index d37e8d453..86c95cb8f 100644 --- a/container/gmap/gmap_hash_int_int_map.go +++ b/container/gmap/gmap_hash_int_int_map.go @@ -426,6 +426,12 @@ func (m *IntIntMap) Merge(other *IntIntMap) { } } +// String returns the map as a string. +func (m *IntIntMap) String() string { + b, _ := m.MarshalJSON() + return gconv.UnsafeBytesToStr(b) +} + // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (m *IntIntMap) MarshalJSON() ([]byte, error) { m.mu.RLock() diff --git a/container/gmap/gmap_hash_int_str_map.go b/container/gmap/gmap_hash_int_str_map.go index 9d131054e..4c6078f2b 100644 --- a/container/gmap/gmap_hash_int_str_map.go +++ b/container/gmap/gmap_hash_int_str_map.go @@ -426,6 +426,12 @@ func (m *IntStrMap) Merge(other *IntStrMap) { } } +// String returns the map as a string. +func (m *IntStrMap) String() string { + b, _ := m.MarshalJSON() + return gconv.UnsafeBytesToStr(b) +} + // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (m *IntStrMap) MarshalJSON() ([]byte, error) { m.mu.RLock() diff --git a/container/gmap/gmap_hash_str_any_map.go b/container/gmap/gmap_hash_str_any_map.go index f5f502eff..b0323649c 100644 --- a/container/gmap/gmap_hash_str_any_map.go +++ b/container/gmap/gmap_hash_str_any_map.go @@ -451,6 +451,12 @@ func (m *StrAnyMap) Merge(other *StrAnyMap) { } } +// String returns the map as a string. +func (m *StrAnyMap) String() string { + b, _ := m.MarshalJSON() + return gconv.UnsafeBytesToStr(b) +} + // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (m *StrAnyMap) MarshalJSON() ([]byte, error) { m.mu.RLock() diff --git a/container/gmap/gmap_hash_str_int_map.go b/container/gmap/gmap_hash_str_int_map.go index 1716b055f..b0af9f967 100644 --- a/container/gmap/gmap_hash_str_int_map.go +++ b/container/gmap/gmap_hash_str_int_map.go @@ -429,6 +429,12 @@ func (m *StrIntMap) Merge(other *StrIntMap) { } } +// String returns the map as a string. +func (m *StrIntMap) String() string { + b, _ := m.MarshalJSON() + return gconv.UnsafeBytesToStr(b) +} + // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (m *StrIntMap) MarshalJSON() ([]byte, error) { m.mu.RLock() diff --git a/container/gmap/gmap_hash_str_str_map.go b/container/gmap/gmap_hash_str_str_map.go index c6922eae6..78c14e192 100644 --- a/container/gmap/gmap_hash_str_str_map.go +++ b/container/gmap/gmap_hash_str_str_map.go @@ -429,6 +429,12 @@ func (m *StrStrMap) Merge(other *StrStrMap) { } } +// String returns the map as a string. +func (m *StrStrMap) String() string { + b, _ := m.MarshalJSON() + return gconv.UnsafeBytesToStr(b) +} + // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (m *StrStrMap) MarshalJSON() ([]byte, error) { m.mu.RLock() diff --git a/container/gmap/gmap_list_map.go b/container/gmap/gmap_list_map.go index 407e5decb..823cd7a54 100644 --- a/container/gmap/gmap_list_map.go +++ b/container/gmap/gmap_list_map.go @@ -510,6 +510,12 @@ func (m *ListMap) Merge(other *ListMap) { }) } +// String returns the map as a string. +func (m *ListMap) String() string { + b, _ := m.MarshalJSON() + return gconv.UnsafeBytesToStr(b) +} + // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (m *ListMap) MarshalJSON() ([]byte, error) { return json.Marshal(gconv.Map(m.Map()))