Skip to content
Search

Go:encoding/json

lastmod 2025-11-20created 2025-11-202 edits

json.Marshal

func Marshal(v interface{}) ([]byte, error)

The signature shows that it takes an argument of type interface{}, which accepts any type in Go, and returns a byte slice.

Example

b, _ := json.Marshal(true)
fmt.Println(b)         // [116 114 117 101]
fmt.Println(string(b)) // "true"

See also

Favorite site

author Zer0 sitemap