Answer the question
In order to leave comments, you need to log in
How to parse json in go?
Good afternoon,
How to parse json in go?
There is the following code
type testRecord struct {
To_socket []string `json:"to_socket"`
Message []string `json:"message"`
}
var ans testRecord
b := []byte(`{"to_socket":"11", "message":"message_texttt"}`) //This is what I get from the client
err = json.Unmarshal(b, &ans)
// log.Printf("%#v", ans)
// log.Printf("To_socket value =" +ans.To_socket) // I want to get the value here
Thank you
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question