Created
May 28, 2020 14:49
-
-
Save uurtech/b8e33baa52087c2c570648d8a7c9a12f to your computer and use it in GitHub Desktop.
Golang Json Parse Empty Interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) | |
func main() { | |
resp, err := http.Get("https://jsonplaceholder.typicode.com/posts/") | |
if err != nil { | |
log.Fatal(err) | |
} | |
body, _ := ioutil.ReadAll(resp.Body) | |
var f interface{} | |
err = json.Unmarshal(body, &f) | |
fmt.Printf("%+v", f) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment