Serializer Problem

I have a new serializer problem.
The old code works.

Result := TJson.SerializeAs<TsngService>(LSvc);

Then I expand the entity with a association.
I get an error with the "DependenciesList"
Here is the new object (a little bit shorter than real)

  [Id('FServiceID', TIdGenerator.None)]
  TsngService = class
    [Column('svc_id', [TColumnProp.Required])]
    FServiceID: TGuid;
    [Column('svc_name', [TColumnProp.Required], 80)]
    FName: string;
    [Column('svc_caption', [TColumnProp.Required], 80)]
    FCaption: string;
    [ManyValuedAssociation([TAssociationProp.Lazy, TAssociationProp.Required], [TCascadeType.SaveUpdate, TCascadeType.Merge, TCascadeType.Remove], 'FServiceID')]
    FDependenciesList: Proxy<TList<TsngDependencies>>;
    function GetDependenciesList: TList<TsngDependencies>;
    constructor Create;
    destructor Destroy; override;
    class function Dependencies(AList: Boolean = True): String;
    property ServiceID: TGuid read FServiceID write FServiceID;
    property Name: string read FName write FName;
    property Caption: string read FCaption write FCaption;
    property DependenciesList: TList<TsngDependencies> read GetDependenciesList;

Ok, I take the TAureliusJsonSerializer.

    Serializer := TAureliusJsonSerializer.Create( TMappingExplorer.Default);
      Result := Serializer.WriteAs<TsngService>(LSvc);

This works, but I have the "F"-Property Names in the JSON string.
{"FName":"abc",FCaption":"abc"} instead {"Name":"abc",Caption":"abc"}

The entities are made from the Datamodeler.
I think I have to change the placement of the [Column ...]
But do I have to do this for all of my entities?
Every time manually?

Thaks for help.


Use TXDataJsonServerSerializer instead of TAureliusJsonSerializer. Indeed Aurelius serializer writes the name of mapped class members (fields in this case).

Thank you, this was the right way.

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.