Golang将哈希表转换为JSON

How to convert a Hashtable into JSON in GoLang ? I want to convert a hash table into a JSON to be able to send it as POST request payload

data := make(map[string]string)
data["a"] = "b"
data["c"] = "d"

How do i convert this to JSON ?

Like that

package main

import (
    "encoding/json"
    "fmt"
)

func main() {
    data := make(map[string]string)
    data["a"] = "b"
    data["c"] = "d"
    bytes, err := json.Marshal(data)
    if err != nil {
        fmt.Println(err)
        return
    }
    text := string(bytes)
    fmt.Println(text)
}

Playground