You may find this official blog helpful: https://blog.golang.org/json-and-go And here's a demo to write more idiomatic codes in this case. https://play.golang.org/p/V1DnpxFctxI
On Wednesday, December 12, 2018 at 2:09:05 PM UTC+8, Olivier GALEOTE wrote: > > Hello, > > I trie to get value from api request > i have this response > [{"id":62,"nom":"TEST","URI":"http://192.168.0.31/param/","IP":"192.168.0.31","MacAdress":"DE:AD:BE:EF:FE:ED","created_at":"2018-12-06T20:44:57.131380+01:00","update_at":"2018-12-06T21:00:40.847034+01:00","Localisation":2,"Type":1}] > > > > i would get the value from nom and IP for example. > > i do a http.get to get the body response, but I can not recover the > values. > > my sample code: > > > resp, err:=http.Get(" > http://192.168.0.28:8000/api/filter/192.168.0.31/") > if nil !=err { > fmt.Printf("%s", err) > log.Fatalln(err) > } else { > defer resp.Body.Close() > contents, err := > ioutil.ReadAll(resp.Body) > if nil !=err { > fmt.Printf("%s", err) > log.Fatalln(err) > } > fmt.Printf("%s\n", > string(contents)) > > > > Can you help me ? > > thank you in advance > > Olivier -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.