Support json.RawMessage in configuration env overrides (#23610)

* support json.RawMessage in env overrides
Этот коммит содержится в:
Doug Lauder
2023-06-07 17:21:58 -04:00
коммит произвёл GitHub
родитель 803d0c6e60
Коммит ac3c0da8ff
6 изменённых файлов: 53 добавлений и 48 удалений

Просмотреть файл

@@ -7,6 +7,7 @@ import (
"bytes"
"encoding/json"
"strings"
"unicode"
"github.com/pkg/errors"
)
@@ -57,7 +58,19 @@ func NewHumanizedJSONError(err error, data []byte, offset int64) *HumanizedJSONE
}
func IsEmptyJSON(j json.RawMessage) bool {
if len(j) == 0 || bytes.Equal(j, []byte("{}")) || bytes.Equal(j, []byte("\"\"")) || bytes.Equal(j, []byte("[]")) {
if len(j) == 0 {
return true
}
// remove all whitespace
jj := make([]byte, 0, len(j))
for _, b := range j {
if !unicode.IsSpace(rune(b)) {
jj = append(jj, b)
}
}
if len(jj) == 0 || bytes.Equal(jj, []byte("{}")) || bytes.Equal(jj, []byte("\"\"")) || bytes.Equal(jj, []byte("[]")) {
return true
}
return false