-
Notifications
You must be signed in to change notification settings - Fork 1
/
xp.go
40 lines (33 loc) · 915 Bytes
/
xp.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
package xparam
//------------------------------------------------------------
// Xparam
//------------------------------------------------------------
func New(vals map[string]interface{}) XP {
return vals
}
//------------------------------------------------------------
// Xparam access for inner xparams
//------------------------------------------------------------
// Gets parameter as array of xparams.
func (xp XP) As_XP(key string) (data XP) {
if val, ok := xp[key]; ok && val != nil {
if axp, ok := val.(map[string]interface{}); ok {
data = axp
}
}
return
}
// Gets parameter as array of xparams.
func (xp XP) As_ArrayXP(key string) (data []XP) {
if val, ok := xp[key]; ok && val != nil {
if arr, ok := val.([]interface{}); ok {
data = []XP{}
for _, obj := range arr {
if axp, ok := obj.(map[string]interface{}); ok {
data = append(data, axp)
}
}
}
}
return
}