动态结构体增加自定义序列化方法
This commit is contained in:
parent
bbf5184314
commit
febf5a63ad
@ -8,6 +8,7 @@
|
||||
package wrapper
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
@ -218,3 +219,12 @@ func (ds *DynamicStruct) Clear() {
|
||||
// 清理掉已设置的字段, 不然实例复用会互相影响
|
||||
ds.structFieldList = make([]reflect.StructField, 0)
|
||||
}
|
||||
|
||||
// MarshalJSON 自定义的序列化方法
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:47 2025/1/24
|
||||
func (ds *DynamicStruct) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(ds.mapData)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user