Привет. Есть json
{
"MailConfig" : {
"username": "*****@gmail.com",
"password": "*****",
"host": "smtp.gmail.com",
"port": "587",
},
"MailTo" : [
"*****@gmail.com",
"*****@yandex.ru",
],
"Types" : [
"Debug",
"Info",
"Warn",
"Error",
"Fatal",
],
"EmailSend" : {
"Debug": false,
"Info": false,
"Warn": false,
"Error": false,
"Fatal": true,
},
"RedisConfig" : {
"Addr": "localhost:6379",
"Password": "*****",
},
"MysqlConfig" : {
"user" : "root",
"pass" : "*****",
"DB" : "log"
}
}
Пытался сделать как то так
package main
import (
"encoding/json"
"io/ioutil"
"log"
)
func main() {
bs, err := ioutil.ReadFile("log.json")
if err != nil {
log.Panicln(err)
}
b := []byte(bs)
type Message struct {
MailConfig, RedisConfig, MysqlConfig map[string]string
MailTo []string
Types []string
EmailSend map[string]bool
}
var m Message
err = json.Unmarshal(b, &m)
if err != nil {
log.Panicln(err)
}
log.Println(m)
}
Терминал говорит
2015/11/05 00:18:33 invalid character '}' looking for beginning of object key string
panic: invalid character '}' looking for beginning of object key string
goroutine 1 [running]:
log.Panicln(0x1843ff40, 0x1, 0x1)
/usr/lib/go/src/log/log.go:334 +0xa5
main.main()
/home/v-smerti/localhost/api/src/microService/config/main.go:28 +0x1d1
exit status 2
Спасибо.