Answer the question
In order to leave comments, you need to log in
Golang and working with json, where is the mistake?
Hello toaster.
Do not tell me how to work with json.
There is y in my application API that returns json and it needs to be accepted by the application on go.
Rummaged through all the docks, but their examples do not work =)
type test struct {
status string `json:"status"`
}
func getRequest(url string) {
client := &http.Client{}
resp, _ := client.Get(url)
defer resp.Body.Close()
f := new(test)
err := json.NewDecoder(resp.Body).Decode(f);
if (err != nil) {
log.Println(err.Error())
}
fmt.Println(f.status)
}
{"status":"error"}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question