gojay icon indicating copy to clipboard operation
gojay copied to clipboard

Return error on unknown object key

Open bramp opened this issue 4 years ago • 0 comments

I would like the gojay codegen tool to have a flag to return a error if an unknown field is encountered.

For example

func (m *Message) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {
	switch k {
	case "type":
		return dec.String(&m.Type)

	case "message":
		return dec.String(&m.Message)

        /////// New code
        default:
		return errUnknownField
	}
	//////
}

bramp avatar Apr 11 '21 21:04 bramp