|
@@ -42,6 +42,10 @@ Simple usage example:
|
|
|
|
|
|
__author__ = 'jieluo@google.com (Jie Luo)'
|
|
|
|
|
|
+try:
|
|
|
+ from collections import OrderedDict
|
|
|
+except ImportError:
|
|
|
+ from ordereddict import OrderedDict #PY26
|
|
|
import base64
|
|
|
import json
|
|
|
import math
|
|
@@ -208,7 +212,8 @@ def _AnyMessageToJsonObject(message, including_default):
|
|
|
"""Converts Any message according to Proto3 JSON Specification."""
|
|
|
if not message.ListFields():
|
|
|
return {}
|
|
|
- js = {}
|
|
|
+ # Must print @type first, use OrderedDict instead of {}
|
|
|
+ js = OrderedDict()
|
|
|
type_url = message.type_url
|
|
|
js['@type'] = type_url
|
|
|
sub_message = _CreateMessageFromTypeUrl(type_url)
|