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

JSON: Precision does not seem to work #400

Closed
xliiauo opened this issue Apr 19, 2021 · 3 comments
Closed

JSON: Precision does not seem to work #400

xliiauo opened this issue Apr 19, 2021 · 3 comments

Comments

@xliiauo
Copy link
Contributor

xliiauo commented Apr 19, 2021

Hi, I have been using minify/json, but it seems the additional Precision field does not seem to take any effects? I've tested this with code and with the online example. Is it just me or the same for everyone else?

image

In the example, I'd like the 1000 to remain as 1000, however it's always 1e3 no matter what value I assign to the Precision.

Thank you very much.

@tdewolff
Copy link
Owner

Precision specifies the maximum amount of precision to retain. That is, it will cut 1.23456789 to 1.234 for example. The second step is minification, which has nothing to do with precision. The fact is that 1000 is equivalent to 1e3, the second version is shorter which is why it is minified as such. Is there a specific reason why this is a problem for you?

@xliiauo
Copy link
Contributor Author

xliiauo commented Apr 19, 2021

Thank you very much for you quick reply, I misunderstood the usage of Precision.

So I'm building API clients and services. Where the request body from clients are minified using the minify/json. However, from the services side, it is unable to unmarshal the minified 1e3 json numbers in the request json into int64 struct fields. So I'm looking for a way to minify json with out modifying the numbers.

Does that make sense?

@tdewolff
Copy link
Owner

Thanks! I've added your PR.

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