i am not getting how should i format the struct in golang so that i can get the list of maps (key/value pairs) in JSON format ? So far i tried with this
package main
import (
"encoding/json"
"fmt"
)
func main() {
map1 := map[string]interface{}{"dn": "abc", "status": "live", "version": 2, "xyz": 3}
map2, _ := json.Marshal(map1)
fmt.Println(string(map2))
}
here it is just printing key/value pairs...
{"dn":"abc","status":"live","version":2,"xyz":3}
but i need output something like this :
[{"dn":"abc","status":"live"},{"version":2,"xyz":3}]