MCPcopy Create free account
hub / github.com/Comfy-Org/registry-backend / PrettifyJSON

Function PrettifyJSON

common/string.go:8–23  ·  view source on GitHub ↗
(input string)

Source from the content-addressed store, hash-verified

6)
7
8func PrettifyJSON(input string) (string, error) {
9 // First unmarshal the input string into a generic interface{}
10 var temp interface{}
11 err := json.Unmarshal([]byte(input), &temp)
12 if err != nil {
13 return "", fmt.Errorf("invalid JSON input: %v", err)
14 }
15
16 // Marshal back to JSON with indentation
17 pretty, err := json.MarshalIndent(temp, "", " ")
18 if err != nil {
19 return "", fmt.Errorf("failed to marshal JSON: %v", err)
20 }
21
22 return string(pretty), nil
23}

Callers 1

PerformSecurityCheckMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected