#1 Yesterday 15:31:40

DirkH
Member
Registered: 2025-09-26
Posts: 7

TOrm with T(Integer)DynArray JSON serialization issues

I want to have the TIntegerDynArray to be recognized as such, i.e. as JSON Array with ObjectToJson and in SQLite DB (for easier debugging).

What do I have to do? I think it might be related to RTTI in Lazarus 3.8 / FPC 3.2.2. If anyhow possible I'd like to stay with the current stable FPC release.

  TParameter = class(TOrm)
  private
    fParameterID: integer;
    fName: RawUtf8;
    fValue: RawUtf8;
    fIntArr: TIntegerDynArray;
  published
    property ParameterID: integer read fParameterID write fParameterID stored AS_UNIQUE;
    property Name: RawUtf8 read fName write fName;
    property Value: RawUtf8 read fValue write fValue;
    property IntArr: TIntegerDynArray read fIntArr write fIntArr;
  end;  

Showmessage(Param.DynArray('IntArr').SaveToJson()); // returns [10,20,30,99]. 
ObjectToJson(TParameter); // is .. "IntArr": "￰AAADAAAAAAoAAAAUAAAAHgAAAA==" (same for entry in sqlite DB)

Offline

#2 Yesterday 19:11:54

DirkH
Member
Registered: 2025-09-26
Posts: 7

Re: TOrm with T(Integer)DynArray JSON serialization issues

Just Found the New Documentation. Great Work!
According to https://github.com/synopse/mORMot2/blob … pter-05.md I think it is intended behaviour because dynarrays are stored as blob.

I'll try (TDoc)Variant. My arrays are typically length<10 and I need to exchange them with different external services via JSON so I think it might be a good solution.

Offline

Board footer

Powered by FluxBB