Skip to content

Commit

Permalink
encoding/protojson: use fd.HasPresence() for editions compatibility
Browse files Browse the repository at this point in the history
This change was originally done by Mike Kruskal in Google-internal cl/515091827.

Change-Id: I5d1588193663249964cf8bc9b9fe9f61d29c98a6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/606756
Reviewed-by: Christian Höppner <hoeppi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
stapelberg committed Aug 20, 2024
1 parent 94ecbc2 commit b643888
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions encoding/protojson/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ func (m unpopulatedFieldRanger) Range(f func(protoreflect.FieldDescriptor, proto
}

v := m.Get(fd)
isProto2Scalar := fd.Syntax() == protoreflect.Proto2 && fd.Default().IsValid()
isSingularMessage := fd.Cardinality() != protoreflect.Repeated && fd.Message() != nil
if isProto2Scalar || isSingularMessage {
if fd.HasPresence() {
if m.skipNull {
continue
}
Expand Down

0 comments on commit b643888

Please sign in to comment.