You are not logged in.
Pages: 1
Ist it possible to use a different "JSONName" for a record property ?
Here is a sample how it could be done ?!
TBaseResponse = record
public
[JsonName('@odata.context')]
odataContext : RawUtf8;
[JsonName('@odata.metadataEtag')]
odataMetadataEtag : RawUtf8;
function FromJSON(const AResponseJSON : RawUtf8) : TresultRec;
function ToJSON : RawUtf8;
end;
implementation
{ TBaseResponse }
function TBaseResponse.FromJSON(const AResponseJSON: RawUtf8): TresultRec;
begin
if Length(AResponseJSON) = 0 then Exit(Result.Fehler('Keine Response erhalten!'));
try
RecordLoadJSON(Self, AResponseJSON, TypeInfo(TBaseResponse));
except
on e : Exception do
Result.Exception(e);
end;
end;
function TBaseResponse.ToJSON: RawUtf8;
begin
Result := RecordSaveJSON(Self, TypeInfo(TBaseResponse), True);
end;Any Idea/Thoughts ?
Rad Studio 12.3 Athens / 13.0 Ganymede
Offline
Actually we use a Stringreplace before and after
Rad Studio 12.3 Athens / 13.0 Ganymede
Offline
Perhaps Rtti.RegisterFromText() can be used for this.
Offline
Pages: 1