bramka
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
type Person struct {
ID uint32
Name, Username, Email string
}
func main() {
url := "https://jsonplaceholder.typicode.com/users"
res, err := http.Get(url)
if err != nil {
log.Fatal(err)
}
data, err := ioutil.ReadAll(res.Body)
defer res.Body.Close()
if err != nil {
log.Fatal(err)
}
person := []Person{}
json.Unmarshal(data, &person)
for _, v := range person {
fmt.Println(v.Name)
}
}
Restu Wahyu Saputra