You are not logged in.
Approximately one month ago handling of the TSQLRawBlob property in ObjectToJson and JsonToObject functions stopped working correctly.
Below is a sample code that demonstrates the problem:
Type
TTestStorage = class(TSQLRecord)
private
FName : RawUTF8;
FPicture : TSQLRawBlob;
published
property Name : RawUTF8 read FName write FName;
property Picture : TSQLRawBlob read FPicture write FPicture;
end;
procedure Test;
var
FS : TTestStorage;
begin
FS := TTestStorage.Create;
try
FS.Name := 'test';
Fs.Picture := StringFromFile('d:\source.png');
ObjectToJSONFile(FS, BlockFileName, [woHumanReadable, woSQLRawBlobAsBase64]);
finally
Fs.Free;
end;
FS := TTestStorage.Create;
try
JSONFileToObject(BlockFileName, Fs);
FileFromString(Fs.Picture, 'd:\saved.png', true);
finally
Fs.Free;
end;
end;
ObjectToJSONFile will generate JSON file:
{
"ID": 0,
"Name": "test",
"Picture": ""iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJzSURBVDhPhZP9S1NRGMdPmU5dtbYh/tof1U+ZEZVBUaYrY8lKM52WJr6Uy0iCHBRoZYmRKWxObRWufo0iSKvNue3evbq7u5dvzzm7rA2CDny4Gzuf5/me89yxf6yq8ekN9z3nJ9x1fiZ8oO8Ym/ZhlPN4AyPE0MN3HtpbU1QqV/UYCYUCiEKJPCdfJEfcmfoI2ltXVBjbQ1QR+wj93NIXKIoCOZoSROQiUjSNWFJFJpvH7UkvL1BPiFVld3jdA5Pv0X//A+GF3bGOPocXvZyJddwkHjzxYUdOQlHzsE+sobGxUa/5rLrPsfbf2F0jHvhDUaQzOXSPetDQ0LBf81lNzzgvUEByNytI7OYE8WQOsVRWxLYNufBzW0ZKycE27ILZbD6g+Ux3fXhFdEykVMSpAJeiGjKdm8e23lrGj0BENOgcXK4sYB10iQIlMUliQhVEEhkRu733Lb7/CiNOv18ZWILJZDqo+ay2o39JnJULEnWU6BmOqQjFMghFMyL2he7X+La5Q8VVXLIvwmg0GjSf1bX1LIqLisQzAi7tCBQEiQTFPndtHl83g6JJ2403MBgMhzSf1Z/vWkA2V/gryQq2iaCkIEDwo53pfIUtf4iOpIo05Qn0Z23zVCAvpG0pLeBigJ7+cFp0PWWdw9jUCiVZQEvH09Xy90B/+upLqDQqLgQiJEZIJH6HdwVSXMUJy3PodLrDPLom87dXLP3Jyy/ErPkI+S3HaJwyTUKiCUh0J2Eq0Nw+y1/fUuzyVdvU6nQftzxDs2VWbGy6OItjbTNFWmdwlDjS8miV9pZil6+9BP9n8bnyDhx+wxyjBv9cEZsxxv4AETtm2YLat/UAAAAASUVORK5CYII="
}
But after executing JSONFileToObject, the Picture property is empty.
Offline
It should be fixed by http://synopse.info/fossil/info/c55e03ca6d
Thanks!
Offline