Skip to content

Intruisive scientific notation when using .dump(); #1698

Description

@Milerius
  • Describe what you want to achieve.

Hello i'm receiving this current json:

{"price":0.0000972439793401814}

I'm writting a financial software and i want to get this price as a string:

"0.0000972439793401814"

  • Describe what you tried.

Unfortunately when i use json::parse and auto price_as_str = my_json["price"].dump()

i got a weird scientific value: "9.722107501034067e-05" <- I lost my precision here also 9722 vs 9724

It's very annoying because my software cannot using floating point numbers, only string and big integer so i feel it's very intruisive from the original json that return me the full value without scientific notation

Even if the answer from the original api is probably strange according to:

This specification allows implementations to set limits on the range and precision of numbers accepted. Since software that implements IEEE 754-2008 binary64 (double precision) numbers [IEEE754] is generally available and widely used, good interoperability can be achieved by implementations that expect no more precision or range than these provide, in the sense that implementations will approximate JSON numbers within the expected precision. A JSON number such as 1E400 or 3.141592653589793238462643383279 may indicate potential interoperability problems, since it suggests that the software that created it expects receiving software to have greater capabilities for numeric magnitude and precision than is widely available.

  • Describe which system (OS, compiler) you are using.

OSX clang-8

  • Describe which version of the library you are using (release version, develop branch).
    v3.6.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions