MCPcopy Create free account
hub / github.com/DNAProject/DNA / GetJsonObjectFromFile

Function GetJsonObjectFromFile

cmd/utils/utils.go:99–112  ·  view source on GitHub ↗
(filePath string, jsonObject interface{})

Source from the content-addressed store, hash-verified

97}
98
99func GetJsonObjectFromFile(filePath string, jsonObject interface{}) error {
100 data, err := ioutil.ReadFile(filePath)
101 if err != nil {
102 return err
103 }
104 // Remove the UTF-8 Byte Order Mark
105 data = bytes.TrimPrefix(data, []byte("\xef\xbb\xbf"))
106
107 err = json.Unmarshal(data, jsonObject)
108 if err != nil {
109 return fmt.Errorf("json.Unmarshal %s error:%s", data, err)
110 }
111 return nil
112}
113
114func GetStoreDirPath(dataDir, networkName string) string {
115 return dataDir + string(os.PathSeparator) + networkName

Callers 2

setGenesisFunction · 0.92
setP2PNodeConfigFunction · 0.92

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected