protoc-gen-typescript-http
protoc-gen-typescript-http copied to clipboard
fix(type): Correctly map proto to json according to spec
In protobuf definition (https://developers.google.com/protocol-buffers/docs/proto3#json), 64 bits numeric types should be interpreted as string in JSON.
Hello @paulip1792, thanks for contributing. I ran the CI pipeline, and youre missing the changes to generated code in your commit.
For my understand have you seen any isues with the current mapping in your applications?
@ericwenn I am using protojson (https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson) to marshal the response and 64 bits integer will be quoted as string value. I guess it's because JS Number can only represent 53 bits integer, so it's defined as string in the spec. In my opinion, in order to make sure it's all type-safe, 64 bits integer should be represented in string. I will make the CI happy if it is accepted change since I know it's a breaking change.
I agree we should address this.
As it turns out we rarely use int64 in our protobuf schemas, so that is likely why we have not noticed it.
Thanks for the PR and reading through the spec!
@paulip1792 Is this still something you want to work on fixing?