#1 Re: mORMot 1 » Invalid value in variant object when assigning floating point variable » 2019-01-31 11:08:26

I have compiled the same example of FPC Version 3.3.1 - the result is correct.

Result:
{"size":123.12345,"Obj":{"size":123.12345}}

Why it does not work the same way in delphi?

#2 mORMot 1 » Invalid value in variant object when assigning floating point variable » 2019-01-30 13:05:40

patron
Replies: 1

I detected invalid value in variant object (TDocVariant) when assigning floating point variable.

Example:

var V1: Variant;
V1 := _Obj([], [dvoAllowDoubleValue]);
V1.size := 123.12345;
V1.Obj := _Obj([], [dvoAllowDoubleValue]);
V1.Obj.size := 123.12345;

Result:
'{"size":123.12345,"Obj":{"size":2.88660792184539E-307}}'

What happened to "Obj.size"?

SynopseCommit: 1.18.5005
Delphi XE2 Update 4
Windows 10

#4 mORMot 1 » Building JSON format using the dvoAllowDoubleValue » 2018-06-05 11:25:29

patron
Replies: 2

I think something is wrong when building JSON using the dvoAllowDoubleValue option for a floating-point value (exponent)

Example:

   TFileEntity = packed record
     double_params: TDoubleDynArray;
   end;

   raw: RawUTF8;
   entity: TFileEntity;
   header: Variant;

   SetLength (entity.double_params, 4);
   entity.double_params [0]: = -12.12345678;
   entity.double_params [1]: = -9.9e-15;
   entity.double_params [2]: = -9.88e-15;
   entity.double_params [3]: = -9.e-15;
   raw: = RecordSaveJSON (entity, TypeInfo (TFileEntity));
   header: = _Json (raw, [dvoReturnNullForUnknownProperty, dvoAllowDoubleValue]);

"raw" return correct value:
{"double_params":[-12.12345678,-9.9E-15,-9.88E-15,-9E-15]}

but, when the conversion to JSON is done, in the position 2 of the double_params array I have the quotes:
header = '{"double_params":[-12.12345678,"-9.9E-15",-9.88E-15,-9E-15]}'

I use dvoAllowDoubleValue but it does not eliminate quotes in this situation:
"-9.9E-15" => bad
-9.9E-15 => ok

ps. Uses the last version of mORMot

Board footer

Powered by FluxBB