I have a GoLang JSON Fetch, sending POST Request Question


I am receiving a JSON request. How do I parse it into individual variables so I can use them for SQL requests (and other things)?

I need "{‘name’:’jude’,’address’:’456 main’}" converted into a name variable and an address variable.

I got this far…

type Member struct {
       Name string `json:"name"`
       Address string `json:"address"`
jsonBody, _ := ioutil.ReadAll(req.Body)

But I can’t get the individual fields out of the json body.

Thank you in advance.


    member := &Member{}
    err := json.Unmarshal(jsonBody, member)


Try the example here: https://go.dev/play/p/2t2KEBiVRDF?v=goprev

Answered By – t3r

Answer Checked By – Cary Denson (GoLangFix Admin)

Leave a Reply

Your email address will not be published.