MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / sanitizeJSONKeysForObject

Function sanitizeJSONKeysForObject

plugins/destination/s3/client/write.go:154–171  ·  view source on GitHub ↗
(data any)

Source from the content-addressed store, hash-verified

152}
153
154func sanitizeJSONKeysForObject(data any) any {
155 // we only care about objects that have keys: present either while nesting or in arrays
156 switch data := data.(type) {
157 case map[string]any:
158 res := make(map[string]any, len(data))
159 for k, v := range data {
160 res[reInvalidJSONKey.ReplaceAllString(k, "_")] = sanitizeJSONKeysForObject(v)
161 }
162 return res
163 case []any:
164 for i, el := range data {
165 data[i] = sanitizeJSONKeysForObject(el)
166 }
167 return data
168 default:
169 return data
170 }
171}

Callers 2

TestSanitizeJSONKeysFunction · 0.85
sanitizeJSONRawMessageFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSanitizeJSONKeysFunction · 0.68