diff --git a/abstruct.go b/abstruct.go index 03a49c7..662f035 100644 --- a/abstruct.go +++ b/abstruct.go @@ -38,4 +38,6 @@ type EasyMap interface { Iterator(IteratorFunc) // ToStruct 转换成结构体 ToStruct(receiver interface{}) error + // ToString 转为字符串 + ToString() string } diff --git a/normal.go b/normal.go index 98d35f9..7b893e4 100644 --- a/normal.go +++ b/normal.go @@ -327,3 +327,14 @@ func (n *normal) ToStruct(receiver interface{}) error { decoder.UseNumber() return decoder.Decode(receiver) } + +// ToString 转字符串 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 20:44 2023/8/15 +func (n *normal) ToString() string { + mapData := n.GetAll() + byteData, _ := json.Marshal(mapData) + return string(byteData) +} diff --git a/segment.go b/segment.go index 40059d0..8b2170e 100644 --- a/segment.go +++ b/segment.go @@ -200,3 +200,14 @@ func (s *segment) ToStruct(receiver interface{}) error { decoder.UseNumber() return decoder.Decode(receiver) } + +// ToString 转字符串 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 20:44 2023/8/15 +func (s *segment) ToString() string { + mapData := s.GetAll() + byteData, _ := json.Marshal(mapData) + return string(byteData) +} diff --git a/sync_normal.go b/sync_normal.go index 21095cb..6092916 100644 --- a/sync_normal.go +++ b/sync_normal.go @@ -269,3 +269,14 @@ func (s *syncMap) ToStruct(receiver interface{}) error { decoder.UseNumber() return decoder.Decode(receiver) } + +// ToString 转字符串 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 20:44 2023/8/15 +func (s *syncMap) ToString() string { + mapData := s.GetAll() + byteData, _ := json.Marshal(mapData) + return string(byteData) +} diff --git a/sync_segment.go b/sync_segment.go index 9924c24..5808e19 100644 --- a/sync_segment.go +++ b/sync_segment.go @@ -176,3 +176,14 @@ func (s *segmentSync) ToStruct(receiver interface{}) error { decoder.UseNumber() return decoder.Decode(receiver) } + +// ToString 转字符串 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 20:44 2023/8/15 +func (s *segmentSync) ToString() string { + mapData := s.GetAll() + byteData, _ := json.Marshal(mapData) + return string(byteData) +}