ahausladen / JsonDataObjects

JSON parser for Delphi 2009 and newer
MIT License
413 stars 160 forks source link

Float value decimal missing when writing #66

Closed bflorac closed 1 month ago

bflorac commented 2 years ago

When importing a Json file, a number that is written as 1.0 is treated as a float. However, when this value is written back out, it writes out as a 1 so the next time it reads it back in, it treats it as an integer.

The occurs in three functions:

function TJsonDataValue.GetValue: string;
function DoubleToText(Buffer: PChar; const Value: Extended): Integer; inline;
class operator TJsonDataValueHelper.Implicit(const Value: TJsonDataValueHelper): string;

Delphi does not have formatting tool that forces a decimal point (well, I guess FormatFloat() can be made to) so in both cases I check for a decimal and add one if missing. (where decimal is JSONFormatSettings.DecimalSeparator).