i have a error to print the data of json file with structs, when i print the result in empty
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
type Users struct {
Users []User `json:"users"`
}
type User struct {
name string `json:"name"`
lastname string `json:"lastname"`
phone string `json:"phone"`
}
func main() {
file, _ := ioutil.ReadFile("./test.json")
data := Users{}
json.Unmarshal([]byte(file), &data)
for i := 0; i < len(data.Users); i++ {
fmt.Println(data.Users[i].name)
fmt.Println(data.Users[i].lastname)
fmt.Println(data.Users[i].phone)
}
}
this is the result when i run me code img