How can I read a JSON file where there is two different objects using Unmarshal ?
JSON example:
This is the structure corresponding to the JSON file.
{
"mysql": {
"address": "127.0.0.1",
"port": "3306",
"user": "user",
"password": "password",
"database": "database"
},
"postgres": {
"address": "127.0.0.2",
"port": "3306",
"user": "user2",
"password": "password2",
"database": "database2"
}
}
Code snippet:
type Database struct {
Address string
Port string
User string
Password string
Database string
}
type Mysql struct {
Database
}
type Postgres struct {
Database
}