flatbuffers: Serializing of doubles into JSON in C++ is broken

Hi,

I have a problem with JSON de/serialization of doubles. Given this minimal example:

table Foobar
{
    mydouble: double;
}
root_type Foobar;

Deserializing of

{
  "mydouble": -1.78814e-07
}

Will result in the correct binary representation of the double. But when serializing back to JSON the resulting JSON looks like this:


{
  "mydouble": -0.0
}

The root cause for this is located in util.h:84 ss << std::fixed << t;

I get the point that in some cases people don’t want to have scientific notation. Still, I think this should be a configurable option of the parser.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 33 (16 by maintainers)

Most upvoted comments

The option was a suggestion, I agree that most important is correctness for sure.