github.com/koko1123/flow-go-1@v0.29.6/admin/commands/helper.go (about) 1 package commands 2 3 import ( 4 "encoding/json" 5 ) 6 7 func ConvertToInterfaceList(list interface{}) ([]interface{}, error) { 8 var resultList []interface{} 9 bytes, err := json.Marshal(list) 10 if err != nil { 11 return nil, err 12 } 13 err = json.Unmarshal(bytes, &resultList) 14 return resultList, err 15 } 16 17 func ConvertToMap(object interface{}) (map[string]interface{}, error) { 18 var result map[string]interface{} 19 bytes, err := json.Marshal(object) 20 if err != nil { 21 return nil, err 22 } 23 err = json.Unmarshal(bytes, &result) 24 return result, err 25 }