msgpack
msgpack copied to clipboard
Why NewDecoder return zero response ?
Why NewDecoder return zero value ?, and not return value from jph, but if i try with json encoding, i'm get response back from jph like this {1 Leanne Graham [email protected]}
.
Code
package main
import (
"fmt"
"net/http"
"github.com/vmihailenco/msgpack/v5"
)
type Person struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
}
func main() {
payload := Person{}
fetch, _ := http.Get("https://jsonplaceholder.typicode.com/users/1")
msgpack.NewDecoder(fetch.Body).Decode(&payload)
defer fetch.Body.Close()
fmt.Println(payload)
}
Response
{0 }