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

Generator for real numbers shouldn't print the fractional part if there is none #66

Open
vinipsmaker opened this issue May 2, 2023 · 3 comments

Comments

@vinipsmaker
Copy link
Contributor

So, I'm developing a Telegram client and I'm using this lib: https://core.telegram.org/tdlib

What I learnt is that a few applications (including tdlib) will reject JSON messages if they include the fractional part (even if it's all zeros). Here's the reply I get from the previous application when sending one of such requests:

{"code":400.000000000000,"@type":"error","message":"Failed to parse JSON object as TDLib request: Can't parse \"559815.000000000\" as an integer"}

So I guess Trial.Protocol's generator needs to detect such patterns and omit the fractional part if it's going to be all zeroes. Otherwise this class of applications will not work.

For my case I can (and will) use a workaround. However I think it's important for Trial.Protocol to up its game, so I'm reporting this issue.

@breese
Copy link
Owner

breese commented May 3, 2023

Sounds like broken applications. JSON has no distinction between integer and floating-point numbers.

@vinipsmaker
Copy link
Contributor Author

JSON has no distinction between integer and floating-point numbers.

That is true. However Trial.Protocol still is generating lots of extraneous unneeded textual output.

@breese
Copy link
Owner

breese commented May 5, 2023

Good point. The floating-point formatting is Trial.Protocol is rather primitive.

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

No branches or pull requests

2 participants