Hi all, I am using json.Unamarshal() api to get back the response values sent as a response by the remote API. But I am unable to get the response values. When printed the output it displayed as {0 } But the same response when converted to string, I could see all the values in it.
Few golang statements made use in the client side are type Rs struct { Id int Name string Email string Phone string } var rs Rs body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalln(err) } json.Unmarshal([]byte(body),&rs) fmt.Println(rs) and the output I got is {0 } But when I converted the response to the string format I could see the response as below sb := string(body) fmt.Printf(sb) {"content":"{\"id\":1,\"name\":\"My Name\",\"email\":\"myn...@myname.com\",\"phone\":\"123456789\"}\n"}2021/10/03 23:34:35 {"content":"{\"id\":1,\"name\":\"My Name\",\"email\":\"myn...@myname.com\",\"phone\":\"123456789\"}\n"} Plz let me know what could be the problem. Thanks Nagaraj Trivedi -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/52088a5f-15b9-4966-8eed-0bfc21cc58f9n%40googlegroups.com.