-
Notifications
You must be signed in to change notification settings - Fork 1
/
legacy.go
44 lines (39 loc) · 913 Bytes
/
legacy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package pprnt
type deprecatedHolder struct {
}
//CleanMap ...
func (dh *deprecatedHolder) CleanMap(clmap map[string]interface{}) map[string]interface{} {
newMap := map[string]interface{}{}
for key, value := range clmap {
if value == nil {
continue
}
switch value := value.(type) {
case map[string]interface{}:
newMap[key] = dh.CleanMap(value)
case []interface{}:
newMap[key] = dh.CleanArray(value)
default:
newMap[key] = value
}
}
return newMap
}
//CleanArray ...
func (dh *deprecatedHolder) CleanArray(clarr []interface{}) []interface{} {
newArr := []interface{}{}
for _, each := range clarr {
if each == nil {
continue
}
switch each := each.(type) {
case map[string]interface{}:
newArr = append(newArr, dh.CleanMap(each))
case []interface{}:
newArr = append(newArr, dh.CleanArray(each))
default:
newArr = append(newArr, each)
}
}
return newArr
}