HTTP GET JSON Body Decode zu einem Struct.
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type Lala struct {
Name string
Vorname string
}
func main() {
hc := http.Client{}
url := "http://localhost:8080/json"
resp, err := hc.Get(url)
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
var res []Lala
json.NewDecoder(resp.Body).Decode(&res)
fmt.Println(res)
}
