结构体支持序列化输出

This commit is contained in:
2023-09-09 14:51:33 +08:00
parent 5f80644a31
commit 098dcddf1f
3 changed files with 7 additions and 4 deletions

View File

@ -100,9 +100,10 @@ func (oj *ownJSON) ConsoleOutput(data interface{}) {
fallthrough
case reflect.Map:
fallthrough
case reflect.Struct:
fallthrough
case reflect.Ptr:
byteData, _ := json.Marshal(data)
_ = json.Indent(&out, []byte(string(byteData)+"\n"), "", "\t")
_ = json.Indent(&out, []byte(oj.MarshalForString(data)+"\n"), "", "\t")
_, _ = out.WriteTo(os.Stdout)
return
case reflect.Int: