You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using JsonFormat.printer().preservingProtoFieldNames() to serialize Protobuf to JSON in Java can make the result incompatible with Python's google.protobuf.json_format.Parse().
while the Python parser expects the following JSON:
{
"underScore": 1
}
which results in the following error:
Traceback (most recent call last):
File "test.py", line 3, in <module>
google.protobuf.json_format.Parse('{"under_score":1}', test_pb2.Test())
File "/usr/local/lib/python2.7/site-packages/google/protobuf/json_format.py", line 332, in Parse
parser.ConvertMessage(js, message)
File "/usr/local/lib/python2.7/site-packages/google/protobuf/json_format.py", line 363, in ConvertMessage
self._ConvertFieldValuePair(value, message)
File "/usr/local/lib/python2.7/site-packages/google/protobuf/json_format.py", line 441, in _ConvertFieldValuePair
raise ParseError(str(e))
google.protobuf.json_format.ParseError: Message type "Test" has no field named "under_score".
The text was updated successfully, but these errors were encountered:
This is a known issue in python JSON support. We already fixed it in our internal code base but it won't be included in opensource util next minor release (version 3.1.x).
Yo!
Using
JsonFormat.printer().preservingProtoFieldNames()
to serialize Protobuf to JSON in Java can make the result incompatible with Python'sgoogle.protobuf.json_format.Parse()
.Example:
The Java code will generate the following JSON:
while the Python parser expects the following JSON:
which results in the following error:
The text was updated successfully, but these errors were encountered: