Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python json_format.MessageToDict() instead of converting the uint64 field to int, it is converted to str #6933

Closed
leosocy opened this issue Nov 23, 2019 · 2 comments
Assignees
Labels

Comments

@leosocy
Copy link

leosocy commented Nov 23, 2019

What version of protobuf and what language are you using?
Version: 3.9.2
Language: Python

What operating system (Linux, Windows, ...) and version?

MacOS

What runtime / compiler are you using (e.g., python version or gcc version)

python 3.6.5

What did you do?

message User {
    uint64 id=1;
}

s = User(id=1).SerializeToString

json_format.MessageToDict(User.FromString(s))

What did you expect to see

{"id": 1}

What did you see instead?

{"id": "1"}

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

@HughKu
Copy link

HughKu commented Nov 30, 2019

@leosocy
This behavior is specified in proto3 spec and here is another thread discussing about this as well.

@anandolee
Copy link
Contributor

anandolee commented Dec 4, 2019

Thank HughKu@ for reply
And {"id": "1"} is the expected behavior as described in proto3 spec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants