You are not logged in.
Pages: 1
In the code below:
Rec.Curr is set to 100 and is serialized correctly:
Json1 = '{"Id":55,"Name":"This is the name.","Curr":100}'
However, it is de-serialized incorrectly in the call to
RecordLoadJSON(Rec, @Json1Copy[1], TypeInfo(TTestRec));
Rec.Curr = 1000000
Json2 = '{"Id":55,"Name":"This is the name.","Curr":1000000}'
program JsonBug;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
SynCommons;
type
TTestRec = packed record
Id: Integer;
Name: string;
Curr: Currency;
end;
const
__TTestRec = 'Id: Integer; Name: string; Curr: Currency;';
var
Rec: TTestRec;
Json1, Json1Copy, Json2: RawUTF8;
begin
try
Rec.Id := 55;
Rec.Name := 'This is the name.';
Rec.Curr := 100;
TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TTestRec), __TTestRec);
Json1 := RecordSaveJSON(Rec, TypeInfo(TTestRec));
Json1Copy := Json1;
Rec := Default(TTestRec);
RecordLoadJSON(Rec, @Json1Copy[1], TypeInfo(TTestRec));
Json2 := RecordSaveJSON(Rec, TypeInfo(TTestRec));
Assert(SameTextU(Json1, Json2));
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Sorry for the recent bug reports.
Offline
Oups... there was indeed an issue!
We have just fixed an issue in record de-serialization of Currency type.
See http://synopse.info/fossil/info/bb7df90946
Thanks a lot for the feedback!
Offline
Pages: 1