MCPcopy Create free account
hub / github.com/CPChain/chain / readJSON

Function readJSON

tests/init_test.go:45–58  ·  view source on GitHub ↗
(reader io.Reader, value interface{})

Source from the content-addressed store, hash-verified

43)
44
45func readJSON(reader io.Reader, value interface{}) error {
46 data, err := ioutil.ReadAll(reader)
47 if err != nil {
48 return fmt.Errorf("error reading JSON file: %v", err)
49 }
50 if err = json.Unmarshal(data, &value); err != nil {
51 if syntaxerr, ok := err.(*json.SyntaxError); ok {
52 line := findLine(data, syntaxerr.Offset)
53 return fmt.Errorf("JSON syntax error at line %v: %v", line, err)
54 }
55 return err
56 }
57 return nil
58}
59
60func readJSONFile(fn string, value interface{}) error {
61 file, err := os.Open(fn)

Callers 1

readJSONFileFunction · 0.85

Calls 1

findLineFunction · 0.85

Tested by

no test coverage detected