Protocol buffer: does the field name change the message?

With the protocol buffer, does changing the name of the message field change to compatibility with it? I could not find any mention of this.

For example: original message

message Person { required string name = 1; required int32 id = 2; optional string email = 3; } 

Change to:

 message Person { required string full_name = 1; required int32 id = 2; optional string email = 3; } 
+5
source share
1 answer

Changing the field name will not affect protobuff encoding or compatibility between applications using proto-definitions that differ only in field names.

The protobuf binary encoding is based on tag numbers, so this must be preserved.

You can even change the type of the field to some extent (check the type table at https://developers.google.com/protocol-buffers/docs/encoding#structure ), provided that its type of wire remains the same, but this requires additional considerations whether, for example, changing uint32 to uint64 safe from the point of view of your application code, and for some definition of β€œbetter” it is best to just define a new field.

Changing the field name will affect the json representation if you use this function.

+8
source

Source: https://habr.com/ru/post/1270416/


All Articles