Merge pull request #98 from ZhouYixun/main

change: replace spaces with indent when generating JSON testcases
This commit is contained in:
debugtalk
2022-02-21 15:17:25 +08:00
committed by GitHub

View File

@@ -97,7 +97,7 @@ func Dump2JSON(data interface{}, path string) error {
return err return err
} }
log.Info().Str("path", path).Msg("dump data to json") 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) err = ioutil.WriteFile(path, file, 0644)
if err != nil { if err != nil {
log.Error().Err(err).Msg("dump json path failed") 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{}) { for key, value := range raw.(map[string]interface{}) {
// convert value to json // convert value to json
if key == "body" { if key == "body" {
b, _ := json.MarshalIndent(&value, "", " ") b, _ := json.MarshalIndent(&value, "", "\t")
value = string(b) value = string(b)
} }
formattedResponse[key] = value formattedResponse[key] = value