Answer the question
In order to leave comments, you need to log in
How to parse JSON in golang?
How to parse a post request in a handler and get the value on GO from there?
Answer the question
In order to leave comments, you need to log in
Example
// AddUserRequest структура с параметрами запроса.
type AddUserRequest struct {
Name string `json:"name"`
Login string `json:"login"`
Password string `json:"password"`
}
func AddUserHandlerFunc(w http.ResponseWriter, r *http.Request) {
var req AddUserRequest
err := json.NewDecoder(r.Body).Decode(&req);
if err != nil {
/// ....
}
// тут у вас будет заполненная структура req
}
{
"name": "Иван",
"login": "Ivan",
"password": "123"
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question