Feature request: option for JsonFormat.Printer to fail if unknown fields are encountered

Open
#28,922 3 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@esrauchg is already working on this.

Since Jul 30, 2026.

Assessment

This issue has not been assessed yet.

Description

feature request json

Currently, com.google.protobuf.util.JsonFormat.Printer silently ignores unknown fields. It would be nice to have a proactive safety check that would fail if the passed in MessageOrBuilder had unknown fields. Ideally, this would apply recursively to any nested messages, and also account for unknown fields in well known message types as well.

While encountering an unknown fields at this layer is most likely an application-level error (that is, the application probably deserialized some binary data without checking if there were any unknown fields, and then later on decided to serialize it as JSON), it would be nice to have a built-in option for this.

Dominant language
C++
Stars
72.2k
Forks
16.4k
Avg merge
1d 8h
Merged PRs (30d)
342

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from protocolbuffers/protobuf

All issues in protocolbuffers/protobuf

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.