Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Stringy enum JSON serialization/deserialization #52

@BenRKarl

Description

@BenRKarl

There appears to be a difference in behavior between wrapped protobufs and raw protobufs loaded directly from a pb2 file.

Serializing a raw protobuf message instance from a pb2 file include the Enum field name in the JSON, i.e.:

'{\n "campaign": {\n "status": "PAUSED"\n }\n}'

While serializing a wrapped protobuf message includes the field number, i.e.:

'{\n "campaign": {\n "status": 3\n }\n}'

Similar issue going in the deserialization direction. When deserializing JSON that includes the field name, this error is raised:

    raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
google.protobuf.json_format.ParseError: Failed to parse campaign field: Failed to parse create field: Failed to parse status field: invalid literal for int() with base 10: 'PAUSED'...

From this line in json_format.

Metadata

Metadata

Assignees

Labels

priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions