diff options
Diffstat (limited to 'cloudflare/json.go')
| -rw-r--r-- | cloudflare/json.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cloudflare/json.go b/cloudflare/json.go new file mode 100644 index 0000000..f91b724 --- /dev/null +++ b/cloudflare/json.go @@ -0,0 +1,25 @@ +// This is a simple example +package cloudflare + +import ( + "encoding/json" +) + +// formatJSON takes an unformatted JSON string and returns a formatted version. +func formatJSON(unformattedJSON string) (string, error) { + var jsonData interface{} + + // Decode the JSON string into an interface + err := json.Unmarshal([]byte(unformattedJSON), &jsonData) + if err != nil { + return "", err + } + + // Re-encode the JSON with indentation for formatting + formattedJSON, err := json.MarshalIndent(jsonData, "", " ") + if err != nil { + return "", err + } + + return string(formattedJSON), nil +} |
