add PrintJson

This commit is contained in:
yanweidong 2025-08-22 12:15:55 +08:00
parent 63a4653eb2
commit fc72fd123d
1 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,10 @@
package utils
import (
"bytes"
"encoding/json"
"fmt"
"os"
"strconv"
"strings"
)
@ -33,3 +37,11 @@ func ParseParams(in map[string]string) map[string]interface{} {
}
return out
}
func PrintJson(v any) {
jsonBy, _ := json.Marshal(v)
var out bytes.Buffer
json.Indent(&out, jsonBy, "", "\t")
out.WriteTo(os.Stdout)
fmt.Printf("\n")
}