JSON numbers in Scientific Notation

Discussions relating to the ScottKlement.com port of the open source YAJL JSON Reader/Generator. This includes the YAJL tool as well as the YAJLR4, YAJLGEN, YAJLINTO and YAJLDTAGEN add-ons from ScottKlement.com. http://www.scottklement.com/yajl/
Post Reply
tim.hurring
Posts: 2
Joined: Wed Sep 28, 2022 9:23 pm

JSON numbers in Scientific Notation

Post by tim.hurring »

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?
Scott Klement
Site Admin
Posts: 305
Joined: Sun Jul 04, 2021 5:12 am

Re: JSON numbers in Scientific Notation

Post by Scott Klement »

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?
tim.hurring
Posts: 2
Joined: Wed Sep 28, 2022 9:23 pm

Re: JSON numbers in Scientific Notation

Post by tim.hurring »

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!
Post Reply