I have a go code to encode struct to json object. Can anybody show me how to decode it back? The thing I don't understand is, to define decoder, what should it be as input?
package main
import "encoding/json"
import "bytes"
//import "os"
import "fmt"
func main() {
var emptyAppendEntriesResponse bytes.Buffer
enc := json.NewEncoder(&emptyAppendEntriesResponse)
d := map[string]int{"apple": 5, "lettuce": 7}
enc.Encode(d)
}
thanks