#1 2015-08-05 21:26:44

ASiwon
Member
From: Poland
Registered: 2015-01-30
Posts: 82

Problem with serializing RawByteString properties

Hello,

I have problem with the following code:

  TUserCredentials = class(TPersistent)
...
  published
    property PasswordEncoded: RawByteString read FPasswordEncoded write FPasswordEncoded;
    property PasswordPlain: RawUTF8 read FPasswordPlain write SetPasswordPlain;
    property UserName: RawUTF8 read FUserName write FUserName;
  end;

procedure Test;
var
  tmp: RawUTF8;
  uc: TUserCredentials;
  valid: Boolean;
begin
  uc := TUserCredentials.Create;
  uc.UserName := 'abc';
  uc.PasswordEncoded := #$f7#$17#$f0#$2f#$4b#$5c#$6e#$e4#$7d#$35#$14#$5b#$e4#$19#$14#$1B#$29;
  tmp := ObjectToJSON(uc);
  JSONToObject(uc, @tmp[1], valid);
end;

On the end of the procedure Test uc structure should be deserialized but in PasswordEncoded property is always empty string. When I  change line where value is assigned to property to the following way:

  uc.PasswordEncoded := BinToBase64(#$f7#$17#$f0#$2f#$4b#$5c#$6e#$e4#$7d#$35#$14#$5b#$e4#$19#$14#$1B#$29);

then after deserialization in property is exactly the same value like before serialization. Is it required to make conversion to base64 format manually or there is a bug in serialization or deserialization procedure?

Btw I think I found small mistake in documentation. In the last line of the section 5.1.11 exists information:

Or via TSQLRestClientURI.TSQLRestClientURI.ForceBlobTransfertTable[] property,

I think it should looks like:

Or via TSQLRestClientURI.ForceBlobTransfertTable[] property,

or even

Or via TSQLRestClient.ForceBlobTransfertTable[] property,

because now property ForceBlobTransfertTable is defined in TSQLRestClient class.


best regards
Adam Siwon

Offline

#2 2015-08-06 06:22:19

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

Re: Problem with serializing RawByteString properties

Define PasswordEncoded as TSQLRawBlob and set the woSQLRawBlobAsBase64 option.

Online

Board footer

Powered by FluxBB