(input string)
| 6 | ) |
| 7 | |
| 8 | func 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 | } |
no outgoing calls
no test coverage detected