Golang wyodrębnia dane interfejsu z map Gilang
package main
import (
"encoding/json"
"fmt"
"net/http"
"reflect"
)
func main() {
url := "https://jsonplaceholder.typicode.com/users/1"
storeData := make(map[string]interface{})
req, _ := http.Get(url)
json.NewDecoder(req.Body).Decode(&storeData)
defer req.Body.Close()
for _, v := range storeData {
if reflect.TypeOf(v) == reflect.TypeOf(storeData) {
subdata := v.(map[string]interface{})
fmt.Println(subdata)
}
}
}
Restu Wahyu Saputra