I've noticed that larger numbers are being generated in scientific notation by yajl_addNum
e.g. the number 25,122,332.47 is being generated as 2.512233247E7
This is causing a problem in the downstream system. Is there a way to avoid scientific notation, or increase the cutoff threshold?
JSON numbers in Scientific Notation
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: JSON numbers in Scientific Notation
That's a floating point number.
I haven't seen yajl_addnum() do that. Are you certain you are using yajl_addnum (rather than yajl_addnumf)? And are you certain that it isn't already in that format before you add it? Can you show us the code you're using?
I haven't seen yajl_addnum() do that. Are you certain you are using yajl_addnum (rather than yajl_addnumf)? And are you certain that it isn't already in that format before you add it? Can you show us the code you're using?
-
- Posts: 2
- Joined: Wed Sep 28, 2022 9:23 pm
Re: JSON numbers in Scientific Notation
Thanks Scott for your prompt reply. This was all my problem. It turns out that the JSON data generated by YAJL was actually fine, it was the tool I was using to display the JSON data that was presenting the numeric value in scientific notation!
Thanks again!
Thanks again!
Re: JSON numbers in Scientific Notation
Hi Team,
I have been facing an issue with JSON involving scientific notation to store small numbers with decimal point values in JSON form ( like - "eKG":2.0E-4 ). How to read these specific values using YAJL Lib functions available from a JSON object already been created by another user ?
YAJL_get_bignumber() or YAJL_get_number() both seems to fail. Please let me know thoughts on this. Much appreciated!
Regards,
Jeron
I have been facing an issue with JSON involving scientific notation to store small numbers with decimal point values in JSON form ( like - "eKG":2.0E-4 ). How to read these specific values using YAJL Lib functions available from a JSON object already been created by another user ?
YAJL_get_bignumber() or YAJL_get_number() both seems to fail. Please let me know thoughts on this. Much appreciated!
Regards,
Jeron
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: JSON numbers in Scientific Notation
Sigh... it's floating point notation, not "scientific" notation...Jeron wrote: ↑Wed Aug 16, 2023 11:13 am I have been facing an issue with JSON involving scientific notation to store small numbers with decimal point values in JSON form ( like - "eKG":2.0E-4 ). How to read these specific values using YAJL Lib functions available from a JSON object already been created by another user ?
Yeah, these routines use the RPG %DEC built-in function to interpret the number, which is the problem -- it doesn't understand floating point notation. This didn't occur to me when I wrote it, and this is the first time someone has mentioned this problem. (The previous discussion was also related to floating point numbers, but not related to yajl_get_number/bignumber.)YAJL_get_bignumber() or YAJL_get_number() both seems to fail. Please let me know thoughts on this. Much appreciated!
Let me think, I'll get back to you.
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: JSON numbers in Scientific Notation
Jeron,
Can you try downloading the updated copy of YAJL from my website and see if it solves the problem for you?
https://www.scottklement.com/yajl/
In this update, YAJL_GET_NUMBER and YAJL_GET_BIGNUMBER should no longer fail when the value is in floating point notation.
Can you try downloading the updated copy of YAJL from my website and see if it solves the problem for you?
https://www.scottklement.com/yajl/
In this update, YAJL_GET_NUMBER and YAJL_GET_BIGNUMBER should no longer fail when the value is in floating point notation.
Re: JSON numbers in Scientific Notation
Thanks Scott for the help. program runs like butter
.
Stay Blessed.

Stay Blessed.