diff --git a/json_utility.go b/json_utility.go index d29894f..ad486d7 100644 --- a/json_utility.go +++ b/json_utility.go @@ -1,6 +1,7 @@ package webutility import ( + "fmt" "net/http" "encoding/json" "errors" @@ -149,7 +150,7 @@ func InitTables(db *ora.Ses, project string) error { mu.Lock() defer mu.Unlock() - json.Unmarshal([]byte(jsonbuf), &payloads) + json.Unmarshal(jsonbuf, &payloads) if len(payloads) == 0 { return errors.New("tables config is corrupt") } @@ -158,16 +159,16 @@ func InitTables(db *ora.Ses, project string) error { // fetchJSON returns a byte slice of JSON configuration file from TABLES_CONFIG table. // Returns an error if it fails. -func fetchJSON(db *ora.Ses, project string) (string, error) { +func fetchJSON(db *ora.Ses, project string) ([]byte, error) { stmt, err := db.Prep(`SELECT JSON_CLOB FROM TABLES_CONFIG WHERE PROJEKAT` + EqualQuotes(project), ora.S) defer stmt.Close() if err != nil { - return "", err + return nil, err } rset, err := stmt.Qry() if err != nil { - return "", err + return nil, err } var data string @@ -175,7 +176,8 @@ func fetchJSON(db *ora.Ses, project string) (string, error) { data = rset.Row[0].(string) } - return data, nil + fmt.Println(data) + return []byte(data), nil } // DecodeJSON decodes JSON data from r to v.