@@ -80,19 +80,19 @@ def MessageToJson(
8080 descriptor_pool = None ,
8181 float_precision = None ,
8282 ensure_ascii = True ,
83- including_default_value_without_presence_fields = False ,
83+ always_print_fields_with_no_presence = False ,
8484):
8585 """Converts protobuf message to JSON format.
8686
8787 Args:
8888 message: The protocol buffers message instance to serialize.
8989 including_default_value_fields: (DEPRECATED: use
90- including_default_value_without_presence_fields to correctly treats proto2
91- and proto3 optional the same). If True, fields without presence (implicit
90+ always_print_fields_with_no_presence which correctly treats proto2
91+ and proto3 optionals the same). If True, fields without presence (implicit
9292 presence scalars, repeated fields, and map fields) and Proto2 optional
9393 scalars will always be serialized. Singular message fields, oneof fields
9494 and Proto3 optional scalars are not affected by this option.
95- including_default_value_without_presence_fields : If True, fields without
95+ always_print_fields_with_no_presence : If True, fields without
9696 presence (implicit presence scalars, repeated fields, and map fields) will
9797 always be serialized. Any field that supports presence is not affected by
9898 this option (including singular message fields and oneof fields).
@@ -119,15 +119,15 @@ def MessageToJson(
119119 use_integers_for_enums ,
120120 descriptor_pool ,
121121 float_precision ,
122- including_default_value_without_presence_fields
122+ always_print_fields_with_no_presence
123123 )
124124 return printer .ToJsonString (message , indent , sort_keys , ensure_ascii )
125125
126126
127127def MessageToDict (
128128 message ,
129129 including_default_value_fields = False ,
130- including_default_value_without_presence_fields = False ,
130+ always_print_fields_with_no_presence = False ,
131131 preserving_proto_field_name = False ,
132132 use_integers_for_enums = False ,
133133 descriptor_pool = None ,
@@ -140,12 +140,12 @@ def MessageToDict(
140140 Args:
141141 message: The protocol buffers message instance to serialize.
142142 including_default_value_fields: (DEPRECATED: use
143- including_default_value_without_presence_fields to correctly treats proto2
143+ always_print_fields_with_no_presence to correctly treats proto2
144144 and proto3 optional the same). If True, fields without presence (implicit
145145 presence scalars, repeated fields, and map fields) and Proto2 optional
146146 scalars will always be serialized. Singular message fields, oneof fields
147147 and Proto3 optional scalars are not affected by this option.
148- including_default_value_without_presence_fields : If True, fields without
148+ always_print_fields_with_no_presence : If True, fields without
149149 presence (implicit presence scalars, repeated fields, and map fields) will
150150 always be serialized. Any field that supports presence is not affected by
151151 this option (including singular message fields and oneof fields).
@@ -166,7 +166,7 @@ def MessageToDict(
166166 use_integers_for_enums ,
167167 descriptor_pool ,
168168 float_precision ,
169- including_default_value_without_presence_fields ,
169+ always_print_fields_with_no_presence ,
170170 )
171171 # pylint: disable=protected-access
172172 return printer ._MessageToJsonObject (message )
@@ -190,11 +190,11 @@ def __init__(
190190 use_integers_for_enums = False ,
191191 descriptor_pool = None ,
192192 float_precision = None ,
193- including_default_value_without_presence_fields = False ,
193+ always_print_fields_with_no_presence = False ,
194194 ):
195195 self .including_default_value_fields = including_default_value_fields
196- self .including_default_value_without_presence_fields = (
197- including_default_value_without_presence_fields
196+ self .always_print_fields_with_no_presence = (
197+ always_print_fields_with_no_presence
198198 )
199199 self .preserving_proto_field_name = preserving_proto_field_name
200200 self .use_integers_for_enums = use_integers_for_enums
@@ -257,7 +257,7 @@ def _RegularMessageToJsonObject(self, message, js):
257257 # Serialize default value if including_default_value_fields is True.
258258 if (
259259 self .including_default_value_fields
260- or self .including_default_value_without_presence_fields
260+ or self .always_print_fields_with_no_presence
261261 ):
262262 message_descriptor = message .DESCRIPTOR
263263 for field in message_descriptor .fields :
@@ -274,10 +274,10 @@ def _RegularMessageToJsonObject(self, message, js):
274274 ):
275275 continue
276276
277- # including_default_value_without_presence_fields doesn't apply to
277+ # always_print_fields_with_no_presence doesn't apply to
278278 # any field which supports presence.
279279 if (
280- self .including_default_value_without_presence_fields
280+ self .always_print_fields_with_no_presence
281281 and field .has_presence
282282 ):
283283 continue
0 commit comments