I have this struct:
type info struct {
InfoType string `json:"Info_type"`
InfoValue string `json:"Info_value"`
}
type Response struct {
infos []info `json:"info"`
}
// Grabs data from SQL then scans into struct
var dp Response
var infoJSON []byte
json.Unmarshal(infoJSON, &dp.infos)
// continues
This output looks like this:
[
{
"Info_type": "example1",
"Info_value": "Example11"
},
{
"Info_type": "example2",
"Info_value": "Example22"
},
{
"Info_type": "example3",
"Info_value": "Example33"
},
{
"Info_type": "example4",
"Info_value": "Example44"
}
]
However, i'd like to mutate this and serve it as:
[
{"Example1": "Example11"},
{"Example2": "Example22"},
{"Example3": "Example33"}
]
How can i go about this?