akheron / jansson

C library for encoding, decoding and manipulating JSON data
http://www.digip.org/jansson/
Other
3.05k stars 808 forks source link

json_real_value() issue #617

Closed westor7 closed 2 years ago

westor7 commented 2 years ago

Hello,

I was trying to use json_real_value(lat) to parse https://proxycheck.io/v2/117.190.245.124?vpn=1&asn=1&risk=1&port=1&days=7 the latitude object value, its working correctly but the only issue is that it's adding 2 extra zeros at the end, do you know why this is happening and how can i fix that? (i'm starter)

Example: lat = json_object_get(value, "latitude"); json_real_value(lat) will return = 34.773200 that should return 34.7732 instead.

woodz- commented 2 years ago

Can you show us your print statement in wehre the zeros show up. Or can you tell us how you observe / generate this output?

Furthermore in math the rule is :

//trailing zeros on fractional part don't change the value
34.773200 == 34.7732; //(true)

It's a formatting issue, nothing more.