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

NodeJS: float certain values as an integer #45

Closed
Wend4r opened this issue Apr 24, 2021 · 2 comments · Fixed by #70
Closed

NodeJS: float certain values as an integer #45

Wend4r opened this issue Apr 24, 2021 · 2 comments · Fixed by #70

Comments

@Wend4r
Copy link
Contributor

Wend4r commented Apr 24, 2021

When does response from the backend on NodeJS, Rest In Pawn cannot read this integer float values through JSONObject.GetFloat().

> JSON.stringify({"float": 1.0})
'{"float":1}'

But JSONObject.GetFloat() works in the case of

> JSON.stringify({"float": 1.1})
'{"float":1.1}'

I suggest to make reading of integers even as float.

@Wend4r Wend4r changed the title NodeJS float certain values as an integer NodeJS: float certain values as an integer Apr 24, 2021
@ErikMinekus
Copy link
Owner

JavaScript does not have distinct types for integers and floats, so JSON.stringify() outputs 1.0 as 1, which I can only interpret as an integer. JSONObject.FromFile() and .FromString() do support the JSON_DECODE_INT_AS_REAL flag, which interprets all numbers as floats, but it's currently not possible to use decoding flags with an HTTP response. I will consider that for the future.

@Wend4r
Copy link
Contributor Author

Wend4r commented Jun 8, 2021

With #52, I can control float and integer values.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants