Answer the question
In order to leave comments, you need to log in
What is the correct way to work with json in Go?
There is json type
{"type": "type_string", "object": {"field1": 1, "field2" : "text"}}
type Event struct {
Type string `json:"type"`
Object []byte `json:"object"`
}
var event Event
err = json.Unmarshal(body, &event)
if err != nil {
log.Fatal(err)
}
Answer the question
In order to leave comments, you need to log in
You need to replace Object []byte with Object json.RawMessage
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question