Skip to content

Commit 113717d

Browse files
committed
avoid unnecessary json decoding/encoding when the value already is a string
Signed-off-by: Guilherme Cassolato <[email protected]>
1 parent ff2afd9 commit 113717d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/json/json.go

+4
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ func ReplaceJSONPlaceholders(source string, jsonData string) string {
157157
}
158158

159159
func StringifyJSON(data interface{}) (string, error) {
160+
_, ok := data.(string)
161+
if ok {
162+
return data.(string), nil
163+
}
160164
if dataAsJSON, err := json.Marshal(data); err != nil {
161165
return "", err
162166
} else {

0 commit comments

Comments
 (0)