Skip to content

json_name is not respected for proto.Field objects using Python proto impl #130

@software-dov

Description

@software-dov

E.g.

import os
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"

import proto
class Squid(proto.Message):
    massKg = proto.Field(proto.INT32, number=1, json_name="mass_in_kilograms")

s = Squid(massKg=20)
j = Squid.to_json(s)
print(j)    # '{"massKg" : 20}', or something like that.

This is only reproducible with the python protobuf implementation.

Editorial: my gut feeling is that this is a bug in proto-plus, or at least that a workaround/fix/correct solution is entirely possible within proto-plus.

Metadata

Metadata

Assignees

Labels

P2A nice-to-fix bugpriority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions