@@ -948,10 +948,14 @@ following rules:
948948 deserialized is language-dependent. Int fields always just preserve their
949949 value.
950950* Changing a single ` optional ` field or extension into a member of a ** new**
951- ` oneof ` is safe and binary compatible. Moving multiple fields into a new
952- ` oneof ` may be safe if you are sure that no code sets more than one at a
953- time. Moving any fields into an existing ` oneof ` is not safe. Likewise,
954- changing a single field ` oneof ` to an ` optional ` field or extension is safe.
951+ ` oneof ` is binary compatible, however for some languages (notably, Go) the
952+ generated code's API will change in incompatible ways. For this reason,
953+ Google does not make such changes in its public APIs, as documented in
954+ [ AIP-180] ( https://google.aip.dev/180#moving-into-oneofs ) . With
955+ the same caveat about source-compatibility, moving multiple fields into a
956+ new ` oneof ` may be safe if you are sure that no code sets more than one at a
957+ time. Moving fields into an existing ` oneof ` is not safe. Likewise, changing
958+ a single field ` oneof ` to an ` optional ` field or extension is safe.
955959
956960## Unknown Fields {#unknowns}
957961
@@ -1116,7 +1120,7 @@ wire is a member of the oneof.
11161120 information (some fields will be cleared) after the message is serialized
11171121 and parsed. However, you can safely move a single field into a ** new** oneof
11181122 and may be able to move multiple fields if it is known that only one is ever
1119- set.
1123+ set. See [ Updating A Message Type ] ( #updating ) for further details.
11201124* ** Delete a oneof field and add it back** : This may clear your currently set
11211125 oneof field after the message is serialized and parsed.
11221126* ** Split or merge oneof** : This has similar issues to moving regular fields.
@@ -1263,12 +1267,19 @@ Proto3 supports a canonical encoding in JSON, making it easier to share data
12631267between systems. The encoding is described on a type-by-type basis in the table
12641268below.
12651269
1266- If a value is missing in the JSON-encoded data or if its value is ` null ` , it
1267- will be interpreted as the appropriate [ default value] ( #default ) when parsed
1268- into a protocol buffer. If a field has the default value in the protocol buffer,
1269- it will be omitted in the JSON-encoded data by default to save space. An
1270- implementation may provide options to emit fields with default values in the
1271- JSON-encoded output.
1270+ When parsing JSON-encoded data into a protocol buffer, if a value is missing or
1271+ if its value is ` null ` , it will be interpreted as the corresponding
1272+ [ default value] ( #default ) .
1273+
1274+ When generating JSON-encoded output from a protocol buffer, if a protobuf field
1275+ has the default value and if the field doesn't support field presence, it will
1276+ be omitted from the output by default. An implementation may provide options to
1277+ include fields with default values in the output.
1278+
1279+ A proto3 field that is defined with the ` optional ` keyword supports field
1280+ presence. Fields that have a value set and that support field presence always
1281+ include the field value in the JSON-encoded output, even if it is the default
1282+ value.
12721283
12731284<table >
12741285 <tbody >
@@ -1557,8 +1568,9 @@ Here are a few of the most commonly used options:
15571568
15581569* `deprecated` (field option): If set to `true`, indicates that the field is
15591570 deprecated and should not be used by new code. In most languages this has no
1560- actual effect. In Java, this becomes a `@Deprecated` annotation. In the
1561- future, other language-specific code generators may generate deprecation
1571+ actual effect. In Java, this becomes a `@Deprecated` annotation. For C++,
1572+ clang-tidy will generate warnings whenever deprecated fields are used. In
1573+ the future, other language-specific code generators may generate deprecation
15621574 annotations on the field's accessors, which will in turn cause a warning to
15631575 be emitted when compiling code which attempts to use the field. If the field
15641576 is not used by anyone and you want to prevent new users from using it,
0 commit comments