是否有使用json编码数组/映射的函数?

Is there a function in golang to encode an array/map using json? Something similar to PHP's json_encode() function is what I'm looking for.

you can encode data structures to json in golang using the encoding/json package like this

package main

import (
    "encoding/json"
    "fmt"
    "os"
)

func main() {
    group := map[string]interface{} {
        "name": "John Doe",
        "age": 112,
    }
    b, err := json.Marshal(group) // this converts the structure into json
    if err != nil {
        fmt.Println("error:", err)
    }
    os.Stdout.Write(b)
}

golang json package