protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Add in patchable _INT64_CONVERTER

Open mikedh opened this issue 1 year ago • 2 comments

An alternative to https://github.com/protocolbuffers/protobuf/pull/16130, which I presume was rejected because you would also have to contribute the option to the mapping specification for every language, add a bunch of tests, etc.

The pitch here: outputting int64 as a string produces results that are defensible as a mapping, but not great for a consumer ("why are my numbers, strings?"). This PR modifies no existing logic, but allows an upstream user who knows what they want to in-place patch the json_format.py without vendoring the entire json_format submodule:

from google.protobuf import json_format

assert json_format._INT64_CONVERTER == str
json_format._INT64_CONVERTER = int

mikedh avatar Aug 14 '24 20:08 mikedh