forked from eBay/libovsdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
row.go
41 lines (36 loc) · 953 Bytes
/
row.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
package libovsdb
import "encoding/json"
// Row is a table Row according to RFC7047
type Row struct {
Fields map[string]interface{}
}
// UnmarshalJSON unmarshalls a byte array to an OVSDB Row
func (r *Row) UnmarshalJSON(b []byte) (err error) {
r.Fields = make(map[string]interface{})
var raw map[string]interface{}
err = json.Unmarshal(b, &raw)
for key, val := range raw {
val, err = ovsSliceToGoNotation(val)
if err != nil {
return err
}
r.Fields[key] = val
}
return err
}
// ResultRow is an properly unmarshalled row returned by Transact
type ResultRow map[string]interface{}
// UnmarshalJSON unmarshalls a byte array to an OVSDB Row
func (r *ResultRow) UnmarshalJSON(b []byte) (err error) {
*r = make(map[string]interface{})
var raw map[string]interface{}
err = json.Unmarshal(b, &raw)
for key, val := range raw {
val, err = ovsSliceToGoNotation(val)
if err != nil {
return err
}
(*r)[key] = val
}
return err
}