JSONMarshalled not working in Delphi XE10 (again)

Viewed 2051

I have a class I want to pass to a datasnap server, but the class contains this field Picture which should be a TPicture but for now I use an integer to avoid getting the marshall error "tkPointer currently not supported" :(

I have tried omitting a field/property "Picture" from getting marshalled by adding [JSONMarshalled(False)] but with no luck.

I have added the units as suggested in the thread here JSONMarshalled not working in Delphi

unit TestObjU;

interface

uses
  Classes, System.Generics.Collections, System.SyncObjs, System.SysUtils,
  JSON, DBXJsonReflect, REST.JSON,
  Data.FireDACJSONReflect, FireDAC.Comp.Client, vcl.ExtCtrls,
  pngimage, graphics, variants,
  GlobalFunctionsU, GlobalTypesU;

{$M+}
{$RTTI EXPLICIT FIELDS([vcPrivate])}
type
  EPerson = class(Exception);
  EPersonsList = class(Exception);

  TGender = (Female, Male);

  TPerson = class(TObject)
  private
    FFirstName: string;
    FLastName: string;
    FId: Integer;
    FGender: TGender;
    FModified : Boolean;
    [JSONMarshalled(False)]
    FPicture: Integer;
//    [JSONMarshalled(False)] FPicture : TPicture;
    function GetName: string;
    procedure SetFirstName(const Value: string);
    procedure SetLastName(const Value: string);
    function GetId: Integer;
    procedure SetGender(const Value: TGender);
    procedure SetModified(const Value: Boolean);

  public
    property Id : Integer read GetId;
    property Name : string read GetName;
    property FirstName : string read FFirstName write SetFirstName;
    property LastName : string read FLastName write SetLastName;
    property Gender : TGender read FGender write SetGender;
    property Modified : Boolean read FModified write SetModified;
//    property Picture : TPicture read FPicture write FPicture;
    [JSONMarshalled(False)]
    property Picture : Integer read FPicture write FPicture;
    function Update : Boolean;
    function Delete : Boolean;

    constructor Create(AId : Integer; AFirstName, ALastName : string; AGender : TGender); overload;
    constructor Create(AFirstName, ALastName : string; AGender : TGender); overload;
    destructor destroy; override;

    function ToJsonString: string;

  end;

But clearly it has no effect on the marshalling, Picture is still there - what am I missing?

function TPerson.ToJsonString: string;
begin
  result := TJson.ObjectToJsonString(self);
end;


08-03-2016 10:26:24 [NORMAL] AddPerson serialized {"firstName":"Donald","lastName":"Duck","id":24,"gender":"Female","modified":false,"picture":92415648}
2 Answers
Related