Need help with getting values

i am not able to fetch values https://play.golang.org/p/7BkXfksp_m6
TIA

This code example retrieves your data: https://play.golang.org/p/w-XQ1_vZJm9
Do you have any questions about it?

The JSON you unmarshal does not map to your struct

type Person struct {
              
                 key  string
                 value  string
         }

See @CurtGreens playground.

But you can define the JSON struct also in one type by just using nested struct definitions . Example:

type GoogleLocationResponse struct {
	Results []struct {
		Geometry struct {
			Location struct {
				Lattitude float32 `json:"lat"`
				Logitude  float32 `json:"lng"`
			} `json:"location"`
		} `json:"geometry"`
	} `json:"results"`
	Status string `json:"status"`
}
2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.