summaryrefslogtreecommitdiffstats
path: root/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/readJson.go
blob: bfab64e696b3071657c943939f2e3be65ada9f2b (plain)
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
package utils

import (
	"os"
	"io/ioutil"
)


//ReadJSON reads the content of a give file and returns as a string
// used for small config files only.
func ReadJSON(path string) string {
	slogger := GetLoggerInstance()
	jsonFile, err := os.Open(path)
	if err!=nil{
		//fmt.Print(err)
		slogger.Errorf("Unable to open file: %s", path)
		slogger.Errorf("Error::: %s", err)

	}else{
		slogger.Infof("Successfully opened config.json")
	}
	
	defer jsonFile.Close()
	byteValue, _ := ioutil.ReadAll(jsonFile)
	s := string(byteValue)
	return s
}