Documentation
¶
Overview ¶
Package encode provides a flexible way to encode and decode Go objects.
Example ¶
var enc Encoder
var err error
enc = GNjson{Pretty: true}
ary1 := []int{1, 2, 3}
jsonRes, err := enc.Encode(ary1)
if err != nil {
panic(err)
}
var ary2 []int
err = enc.Decode(jsonRes, &ary2)
if err != nil {
panic(err)
}
fmt.Println(ary1[0] == ary2[0])
Output: true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Encoder ¶
type Encoder interface {
//Encode takes a Go object and converts it into bytes
Encode(input interface{}) ([]byte, error)
// Decode takes an input of bytes and decodes it into Go object.
Decode(input []byte, output interface{}) error
}
Encoder interface allows to switch between different encoding types.
Click to show internal directories.
Click to hide internal directories.