Skip to content

The generated marshallers ignore the omitzero tag #426

@gnvk

Description

@gnvk

The "omitzero" JSON tag has been introduced in Go 1.24. However, the easyjson generated functions completely ignore it.

For example this test succeeds without easyjson

type S struct {
	N int `json:"n,omitzero"`
}

func TestEasyjsonOmitZero(t *testing.T) {
	s := S{N: 0}
	b, err := json.Marshal(s)
	require.NoError(t, err)
	assert.Equal(t, "{}", string(b))
}

But if we generated JSON marshallers for S, it fails

Error:      	Not equal:
							expected: "{}"
							actual  : "{\"n\":0}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions