From cb6de8f56df81e8a54c90d11527cfed190b2176d Mon Sep 17 00:00:00 2001 From: Eason <291028775@qq.com> Date: Mon, 21 Feb 2022 15:13:25 +0800 Subject: [PATCH] Update for JSON formatting A small suggestion is to use /t for indentation and line feed in JSON formatting --- internal/builtin/function.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/builtin/function.go b/internal/builtin/function.go index 434b082d..656fedc3 100644 --- a/internal/builtin/function.go +++ b/internal/builtin/function.go @@ -97,7 +97,7 @@ func Dump2JSON(data interface{}, path string) error { return err } log.Info().Str("path", path).Msg("dump data to json") - file, _ := json.MarshalIndent(data, "", " ") + file, _ := json.MarshalIndent(data, "", "\t") err = ioutil.WriteFile(path, file, 0644) if err != nil { log.Error().Err(err).Msg("dump json path failed") @@ -138,7 +138,7 @@ func FormatResponse(raw interface{}) interface{} { for key, value := range raw.(map[string]interface{}) { // convert value to json if key == "body" { - b, _ := json.MarshalIndent(&value, "", " ") + b, _ := json.MarshalIndent(&value, "", "\t") value = string(b) } formattedResponse[key] = value