Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JsonToYaml ¶
JsonToYaml converts a JSON string into a YAML string.
The function takes a JSON string as input and attempts to unmarshal it into an empty interface. If the unmarshalling is successful, it marshals the data back into a YAML string using the YAML package.
On success, the function returns the YAML string and a nil error. If there is any error during the conversion, it returns an empty string and the corresponding error.
func TryParse ¶
TryParse attempts to parse and execute a template with the given JSON string.
The function takes two string inputs - a template string (tmpStr) and a JSON string. It attempts to parse the template string using the "text/template" package. If there is any error during parsing, the function returns the original JSON string.
If the template is parsed successfully, the function attempts to execute the template using the provided JSON string as input data. If there is any error during execution, the function returns the original JSON string.
On successful execution, the function returns the resulting string from the executed template.
func ValidJSON ¶
ValidJSON checks if the provided string is a valid JSON object.
The function takes a string as input and attempts to unmarshal it into a map[string]any using the JSON package. If the unmarshalling is successful, it returns true, indicating that the string is a valid JSON object. Otherwise, it returns false.
Types ¶
This section is empty.