Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any explanation on unknown field? #3395

Closed
AjeyaGupta opened this issue Jul 19, 2017 · 3 comments
Closed

Any explanation on unknown field? #3395

AjeyaGupta opened this issue Jul 19, 2017 · 3 comments

Comments

@AjeyaGupta
Copy link

I am relatively newbie in google protocol buffers. I was reading various differences between proto2 and proto3. One difference that I found was the removal of unknown fields from proto3 syntax. Any help to understand the usage of 'unknown fields' in proto2 better will be greatly appreciated.

Thank You.

@acozzette
Copy link
Member

Unknown fields are fields that fields that are parsed but which are not recognized based on the schema from the .proto file. Ordinarily these come up when you have code with a newer version of the schema talking to code with an older version. In proto2 these unknown fields are preserved when the message is serialized, so that for example you can parse a message and reserialize it without disturbing any unknown fields. In proto3 we originally removed this behavior, so that unknown fields were dropped at parsing time. However, we have since reversed that decision and we're now working on updating proto3 so that it has the same behavior as proto2, and preserves unknowns.

@dhruv459
Copy link

@acozzette Is the older behavior in place with proto3? Can we inject the unknown fields in a proto3 message and expect them to be retained after the serialize - deserialize operations?

@acozzette
Copy link
Member

Proto3 now preserves unknowns again, so they will be retained after a serialize-parse trip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants