diff --git a/pkg/utils/json_utils.go b/pkg/utils/json_utils.go index f509a4e62..aeb8ad4b6 100644 --- a/pkg/utils/json_utils.go +++ b/pkg/utils/json_utils.go @@ -44,7 +44,14 @@ func WriteToFileAsJSON(filePath string, data any, fileMode os.FileMode) error { if err != nil { return err } - err = os.WriteFile(filePath, []byte(j), fileMode) + + // Convert data to indented JSON + indentedJSON, err := json.MarshalIndent(json.RawMessage(j), "", " ") + if err != nil { + return err + } + + err = os.WriteFile(filePath, indentedJSON, fileMode) if err != nil { return err } @@ -53,7 +60,7 @@ func WriteToFileAsJSON(filePath string, data any, fileMode os.FileMode) error { // ConvertToJSON converts the provided value to a JSON-encoded string func ConvertToJSON(data any) (string, error) { - var jc = jsoniter.Config{ + jc := jsoniter.Config{ EscapeHTML: true, ObjectFieldMustBeSimpleString: false, SortMapKeys: true, @@ -69,7 +76,7 @@ func ConvertToJSON(data any) (string, error) { // ConvertToJSONFast converts the provided value to a JSON-encoded string using 'ConfigFastest' config and json.Marshal without indents func ConvertToJSONFast(data any) (string, error) { - var jc = jsoniter.Config{ + jc := jsoniter.Config{ EscapeHTML: false, MarshalFloatWith6Digits: true, ObjectFieldMustBeSimpleString: true, @@ -86,7 +93,7 @@ func ConvertToJSONFast(data any) (string, error) { // ConvertFromJSON converts the provided JSON-encoded string to Go data types func ConvertFromJSON(jsonString string) (any, error) { - var jc = jsoniter.Config{ + jc := jsoniter.Config{ EscapeHTML: false, MarshalFloatWith6Digits: true, ObjectFieldMustBeSimpleString: true,