github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/jsonutils/utils.go (about) 1 // Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. 2 3 package jsonutils 4 5 import ( 6 "bytes" 7 "encoding/json" 8 "testing" 9 ) 10 11 func PrintT(obj any, t *testing.T) { 12 data, err := json.MarshalIndent(obj, "", " ") 13 if err != nil { 14 t.Log(err) 15 } else { 16 t.Log(string(data)) 17 } 18 } 19 20 func Equal(obj1 any, obj2 any) bool { 21 data1, err := json.Marshal(obj1) 22 if err != nil { 23 return false 24 } 25 26 data2, err := json.Marshal(obj2) 27 if err != nil { 28 return false 29 } 30 31 return bytes.Equal(data1, data2) 32 }