Do not emit unset fields in JSON #280

Open
opened 2025-12-28 18:07:39 +00:00 by sami · 1 comment
Owner

Originally created by @cthulhu-rider on GitHub (Sep 16, 2025).

I'm always frustrated when message binary does not change but JSON does

currently, when proto message is extended with new field(s), they start to appear in producing JSON even when unset. I see following cons in this:

  • change as such
  • bigger size with the same utility

i don't see any pros

Describe the solution you'd like

omit empty fields

see nspcc-dev/neofs-sdk-go@3c286a4986/internal/proto/encoding.go (L70)

Originally created by @cthulhu-rider on GitHub (Sep 16, 2025). ## Is your feature request related to a problem? Please describe. I'm always frustrated when message binary does not change but JSON does currently, when proto message is extended with new field(s), they start to appear in producing JSON even when unset. I see following cons in this: - change as such - bigger size with the same utility i don't see any pros ## Describe the solution you'd like omit empty fields see https://github.com/nspcc-dev/neofs-sdk-go/blob/3c286a4986a831ce6c9a80b20fc60992e3cbaa89/internal/proto/encoding.go#L70
Author
Owner

@roman-khimov commented on GitHub (Sep 16, 2025):

Related to #681, there is omitzero starting from 1.24 which is much more convenient to use.

@roman-khimov commented on GitHub (Sep 16, 2025): Related to #681, there is `omitzero` starting from 1.24 which is much more convenient to use.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-sdk-go#280
No description provided.