#1 2015-03-02 08:57:37

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

Bug in ObjectToJSON when Object has TSQLRawBlob field

The test.txt file content: (has Unicode symbol »)

Read more »
Next Line

Loading file content to the Value property and generating JSON file:

Type
  TMyRecord = class(TSQLRecord)
  private
   FValue          : TSQLRawBlob;
  published
  property Value: TSQLRawBlob read FValue write FValue;
end;
...

FRecord := TMyRecord.Create;
try
 FRecord.Value := StringFromFile('d:\test.txt');
 ObjectToJSONFile(FRecord, 'd:\output.txt');
finally
 FRecord.free;
end;

Output file (the value property does not contain text after »:

{"ID":0,"Value":"Read more "}

I think the problem is in procedure TTextWriter.AddAnyAnsiString(..)

Maybe we should check codepage:

  case CodePage of
  CP_SQLRAWBLOB:
    Add(pointer(s),0,Escape);  // direct write of TSQLRawBlob content
....

Offline

#2 2015-03-02 10:27:11

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

Re: Bug in ObjectToJSON when Object has TSQLRawBlob field

I suspect it should be written as base64 text.
See http://synopse.info/fossil/info/ef8602d548

Hope it helps.

Offline

Board footer

Powered by FluxBB