Skip to content

Return error on unknown object key #161

Description

@bramp

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
	}
	//////
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions