Skip to content

Go:encoding/json

json.Marshal

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

시그니처를 보면 Go에서 모든 타입을 받을수 있는 interface{} 타입을 인자로 받고 바이트 슬라이스를 반환한다는 것을 알 수 있다.

Example

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

See also

Favorite site