You could write a function to do that for you. On Thu, 30 Jul 2020, 09:45 Brian Candler, <[email protected]> wrote:
> I want to do a json.Unmarshal of []byte data whilst also getting the > disallowUnknownFields behaviour. Is there any tidier way than this > <https://play.golang.org/p/oSLBiFxj4kt>? > > dec := json.NewDecoder(bytes.NewReader(data)) > dec.DisallowUnknownFields() > var v mystruct > err := dec.Decode(&v) > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/5c1c7101-8ead-46b2-9e58-8b7f26203be0o%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/5c1c7101-8ead-46b2-9e58-8b7f26203be0o%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAJhgaciA82muYrh4-rK2HRjP6CdG75uDvo3QaovgHMm6YVs93A%40mail.gmail.com.
