25 lines
524 B
Go
25 lines
524 B
Go
![]() |
package azurerm
|
||
|
|
||
|
import "encoding/json"
|
||
|
|
||
|
// Takes a value containing JSON string and passes it through
|
||
|
// the JSON parser to normalize it, returns either a parsing
|
||
|
// error or normalized JSON string.
|
||
|
func normalizeJsonString(jsonString interface{}) (string, error) {
|
||
|
var j interface{}
|
||
|
|
||
|
if jsonString == nil || jsonString.(string) == "" {
|
||
|
return "", nil
|
||
|
}
|
||
|
|
||
|
s := jsonString.(string)
|
||
|
|
||
|
err := json.Unmarshal([]byte(s), &j)
|
||
|
if err != nil {
|
||
|
return s, err
|
||
|
}
|
||
|
|
||
|
bytes, _ := json.Marshal(j)
|
||
|
return string(bytes[:]), nil
|
||
|
}
|