Convert map[string]interface{} to json string
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
// map data
mapData := map[string]interface{}{
"Name": "noknow",
"Age": 2,
"Admin": true,
"Hobbies": []string{"IT","Travel"},
"Address": map[string]interface{}{
"PostalCode": 1111,
"Country": "Japan",
},
"Null": nil,
}
// Convert map to json string
jsonStr, err := json.Marshal(mapData)
if err != nil {
fmt.Println(err)
}
|
No notes link to this note