change JSON property name

Hi Everybody,

I'm using TMS XData\Demos\Swagger, and I put a new service implementation

i have a test class for example like:

  [Entity, Automapping ]
  TTest = class
  strict private
    Fid: TGUID;
  public
    [Column('label')] // or something
    name: string;
    property id: TGUID read Fid write Fid;
  end;

and i want to change the property "name" into "label" in JSON answer, is there any mapping [special-tag] that I can use?

now the response is like:

Response body
{
  "$id": 1,
  "id": "9E343ABD-D97C-4411-86BF-AD2E13BE71F3",
  "name": "John John" 
}

but I want to get a response like:

Response body
{
  "$id": 1,
  "id": "9E343ABD-D97C-4411-86BF-AD2E13BE71F3",
  "label": "John John" 
}

So is that any mapping special-tag that can change from field_name to a custom string?

Thanks,
Mihai

For all Delphi classes that are not Aurelius entities, you can use JsonProperty attribute: JSON Format | TMS XData documentation.

For Aurelius entities - which seems to be the case, you can create a fake property named label, exclude the old one from JSON and include the new one using XDataExcludeProperty and XDataIncludeProperty attributes: JSON Format | TMS XData documentation.