aboutsummaryrefslogtreecommitdiff
path: root/python/google/protobuf/json_format.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/google/protobuf/json_format.py')
-rw-r--r--python/google/protobuf/json_format.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/python/google/protobuf/json_format.py b/python/google/protobuf/json_format.py
index 8d338d3e..ce1db7d7 100644
--- a/python/google/protobuf/json_format.py
+++ b/python/google/protobuf/json_format.py
@@ -396,11 +396,7 @@ def Parse(text, message, ignore_unknown_fields=False):
"""
if not isinstance(text, six.text_type): text = text.decode('utf-8')
try:
- if sys.version_info < (2, 7):
- # object_pair_hook is not supported before python2.7
- js = json.loads(text)
- else:
- js = json.loads(text, object_pairs_hook=_DuplicateChecker)
+ js = json.loads(text, object_pairs_hook=_DuplicateChecker)
except ValueError as e:
raise ParseError('Failed to load JSON: {0}.'.format(str(e)))
return ParseDict(js, message, ignore_unknown_fields)
@@ -486,7 +482,7 @@ class _Parser(object):
('Message type "{0}" has no field named "{1}".\n'
' Available Fields(except extensions): {2}').format(
message_descriptor.full_name, name,
- message_descriptor.fields))
+ [f.json_name for f in message_descriptor.fields]))
if name in names:
raise ParseError('Message type "{0}" should not have multiple '
'"{1}" fields.'.format(