Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why NewDecoder return zero response ? #337

Open
restuwahyu13 opened this issue Jun 20, 2022 · 0 comments
Open

Why NewDecoder return zero response ? #337

restuwahyu13 opened this issue Jun 20, 2022 · 0 comments

Comments

@restuwahyu13
Copy link

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 Sincere@april.biz}.

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  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant