From f1a0d18ac19d0db4f7060ea5a5c662348118e399 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 1 Jan 2024 15:31:33 -0600 Subject: initial commit of cloudflare api Signed-off-by: Jeff Carr --- json.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 json.go (limited to 'json.go') diff --git a/json.go b/json.go new file mode 100644 index 0000000..b7c71a8 --- /dev/null +++ b/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 +} -- cgit v1.2.3