Golang encoding
From wikinotes
Interface
The encoding libraries share a common interface, making it easy to swap between serialization formats.
Simply swap out the library (herejson
) for your desired output format.serialize
type User struct { Id: int Name: string } user := User{1, "will"} bytes, err := json.Marshall(&user)deserialize
var mapping map[string]int var serialized := []byte(`{"a": 1}`) json.Unmarshall(serialized, &mapping)
Libraries
Builtin
golang encoding/json golang encoding/xml golang encoding/csv