#1 2018-05-15 08:26:55

ertank
Member
Registered: 2016-03-16
Posts: 163

RecordSaveJSON() returning simple "{}" as result

Hello,

In the project I am working on, if I try to serialize below record it simply returns "{}" for my *second* call of it.

  TPromotion = packed record
    &type: Byte;
    amount: Integer;
    ticketMsg: string;
  end;

  TStItem = packed record
    &type: Byte;
    subType: Byte;
    deptIndex: Byte;
    unitType: Byte;
    amount: UInt32;
    currency: UInt16;
    count: UInt32;
    flag: UInt32;
    countPrecition: Byte;
    pluPriceIndex: Byte;
    name: string;
    barcode: string;
    firm: string;
    invoiceNo: string;
    subscriberId: string;
    tckno: string;
    Reserved: UInt32;
    Date: string;
    promotion: TPromotion;
    OnlineInvoiceItemExceptionCode: UInt16;
  end;

There is no TTextWriter custom format defined or any specific options for serialization/de-serialization. They are all defaults.
There is a procedure variable (not a form wide or project wide) used to hold record information. I change some values in it and serialize.
When I debug run, I see that record is fine. Contains information.
If I am to test it in a new project to see if I can reproduce the problem, I see that it works every and each time I call the function. So, I have something in my formal project that cause second call to return empty json.

My question is: Are there any possible case(s) that results to receive "{}" to a call to RecordSaveJSON() function?

Thanks & regards,
Ertan


P.S. I just realize that this is not just that record I am having problem. After first pass, any record serialization attempt either returns a simple "{}" as a result or I get an access violation at address 00000004.

Last edited by ertank (2018-05-15 08:34:41)

Offline

#2 2018-05-15 09:22:50

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: RecordSaveJSON() returning simple "{}" as result

Perhaps you're referencing some old SynCommons.pas/dcu or  some of the variables you're sending is overwritten. SynCommons itself should be OK.

Offline

#3 2018-05-15 09:53:38

ertank
Member
Registered: 2016-03-16
Posts: 163

Re: RecordSaveJSON() returning simple "{}" as result

Turning on Range check showed me the problem. Nasty out of range writing in a dynamic record variable. That probably leads to memory corruption and my luck it hit SynCommons functions memory area.

Sorry for the noise.

Offline

Board footer

Powered by FluxBB