aboutsummaryrefslogtreecommitdiff
path: root/python/google/protobuf/internal/json_format_test.py
diff options
context:
space:
mode:
authorJie Luo <jieluo@google.com>2016-05-17 13:01:27 -0700
committerJie Luo <jieluo@google.com>2016-05-17 15:14:53 -0700
commitb01b1a8ebeb83689d606546d5867009d380cdecd (patch)
tree2cbd5688d0692da360082ef4777ca3dedb6b08e8 /python/google/protobuf/internal/json_format_test.py
parente4ca694cdfe8b817f14b07f4d5b88f9dc9e11d4a (diff)
downloadprotobuf-b01b1a8ebeb83689d606546d5867009d380cdecd.tar.gz
protobuf-b01b1a8ebeb83689d606546d5867009d380cdecd.tar.bz2
protobuf-b01b1a8ebeb83689d606546d5867009d380cdecd.zip
JSON format for Any message must print @type first, use OrderedDict instead of {}
Diffstat (limited to 'python/google/protobuf/internal/json_format_test.py')
-rw-r--r--python/google/protobuf/internal/json_format_test.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/google/protobuf/internal/json_format_test.py b/python/google/protobuf/internal/json_format_test.py
index bdc9f49a..eec1f56f 100644
--- a/python/google/protobuf/internal/json_format_test.py
+++ b/python/google/protobuf/internal/json_format_test.py
@@ -458,6 +458,22 @@ class JsonFormatTest(JsonFormatBase):
'}\n'))
parsed_message = json_format_proto3_pb2.TestAny()
self.CheckParseBack(message, parsed_message)
+ # Must print @type first
+ test_message = json_format_proto3_pb2.TestMessage(
+ bool_value=True,
+ int32_value=20,
+ int64_value=-20,
+ uint32_value=20,
+ uint64_value=20,
+ double_value=3.14,
+ string_value='foo')
+ message.Clear()
+ message.value.Pack(test_message)
+ self.assertEqual(
+ json_format.MessageToJson(message, False)[0:68],
+ '{\n'
+ ' "value": {\n'
+ ' "@type": "type.googleapis.com/proto3.TestMessage"')
def testWellKnownInAnyMessage(self):
message = any_pb2.Any()