You are not logged in.
Pages: 1
Hi!
this code
var
obj: Variant;
z: double;
begin
obj := _JsonFast('{"x": 8.1E-2}');
z1 := obj.x;
Memo1.Lines.Add(Format('x: %f', [z]));
end.
produces output "x: 8.10" instead of 0.081, why?
Last edited by mvg7 (2021-10-03 01:35:47)
Offline
You need to enable float process.
Floats may not be consistent when converted back and forth.Use _JsonFastFloat() as documented.
Thanks, I dont see a _JsonFastFloat anywhere even if searching the mORMot-master.zip sources
Offline
You should have read the documentation/comments to the end:
...
// - will handle only currency for floating point values to avoid precision
// loss: use _JsonFastFloat() instead if you want to support double values
function _JsonFast(const Json: RawUtf8): variant;
Offline
It's here (in mORMot2) - https://github.com/synopse/mORMot2/blob … .pas#L2197
There is no analog in mORMot1
Last edited by mpv (2021-10-04 11:09:27)
Offline
You are right about the source code.
But this is clearly stated in the documentation:
https://synopse.info/files/html/Synopse … l#TITL_194
I have made explicit that dvoAllowDoubleValue option is not included by default in mORMot 1 comments too. It was confusing.
- also introducing _JsonFastFloat() wrapper.
https://synopse.info/fossil/info/7de179b819
Offline
Pages: 1