-
Notifications
You must be signed in to change notification settings - Fork 349
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
toJSON not verifiying ints are actualy ints #433
Comments
Ah yeah, that's a good point. Probably both https://github.com/stephenh/ts-proto/blob/main/src/main.ts#L279 So that they are conditionally included in the output (i.e. only if you're actually using that data type), around these line: https://github.com/stephenh/ts-proto/blob/main/src/main.ts#L996 https://github.com/stephenh/ts-proto/blob/main/src/main.ts#L1225 If you'd like to submit a PR, that'd be great! |
see here PR. note1: I also think there is need to change only the note2: no need to check the numbers when using note3: it might be smart to validate all the types, ex make sure no overflow for small types, signed/unsigned etc... |
@yoavmil I picked up your initial PR as #444 and merged that. FWIW I'm kinda wondering, in retrospect, if blowing up inside of I still merged the |
🎉 This issue has been resolved in version 1.94.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
If a proto has an int/uint, at the
ts
side it isnumber
, therefor can get any floating point number. when trying to create a JSON from it, there is no error, or rounding to nearest int. and later on, in my case, when parsing it at a C++ server with the protof utils, it fails.It will be best to make sure, that the data fits the data type. For me, a workaround was to encode & decode before writing the JSON.
Cheers.
The text was updated successfully, but these errors were encountered: