#1 2015-05-06 12:55:37

DigDiver
Member
Registered: 2013-04-29
Posts: 137

TSQLRawBlob property in ObjectToJson and JsonToObject functions

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

#2 2015-05-06 15:46:29

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,662
Website

Re: TSQLRawBlob property in ObjectToJson and JsonToObject functions

It should be fixed by http://synopse.info/fossil/info/c55e03ca6d

Thanks!

Offline

Board footer

Powered by FluxBB