Sweet. Thanks gents. Still fairly new to Golang. I followed Matt's example and was able to get it working.
On Sun, Jan 22, 2017 at 6:52 PM, Matt Harden <matt.har...@gmail.com> wrote: > Note that you can't use lowercase struct field names with encoding/json > anyway, because fields must be exported for encoding/json to see them, and > fields are exported by starting them with an uppercase letter. So if you > want the JSON field names to be lower case, you have to use struct tags. I > think that while Tamás's solution should work, you probably just want the > type field to be in LoginRequest itself: > > type LoginRequest struct { > Type string `json:"type"` > User string `json:"username"` > Password string `json:"password"` > } > > > On Sun, Jan 22, 2017 at 12:48 PM Tamás Gulácsi <tgulacs...@gmail.com> > wrote: > >> TL;DR; use struct tags to specify marshal/unmarsal names. >> >> type LoginRequest struct { >> >> User string `json:"username"` >> Passw string `json:"password"` >> } >> >> ... >> >> SetBody(struct { >> Type string `json:"type"` >> LoginRequest >> }{ >> Type: "LoginRequest", LoginRequest:{User:"my_admin", >> Passw:"testing123"}}) >> >> >> >> -- >> 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. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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. For more options, visit https://groups.google.com/d/optout.