In addition to using TRoComplexType against RoSDK based servers, we use it to model structures against different JSON based WEB services. That works fine using the TRoJSONMessage (with som trixing), but we run into problems with reserved words in structures. For exampe field names like class and type.
It would been great if the JSON serializer would respect the RoName attribute. Ie.
[RoDocumentation(‘DGClass’)]
[RoName(‘Class’)]
property Class_: integer read FClass write FClass;
function TRORTTISerializerHelper.GetSoapName(p: TRttiProperty): string;
var
la: ROCustomAttribute;
begin
Result := p.Name;
for la in p.ROGetAttributes<ROCustomAttribute> do
if SameText(la.Name,'soapname') then begin
result := la.Value;
Exit;
end;
end;
replace p.Name with GetSoapName(p) in ReadRTTIObject/WriteRTTIObject methods of this helper
after this, this code
TMyStruct = class(TROComplexType)
private
fclass_: string;
published
[ROCustom('soapname', 'class')]
property class_: string read fclass_ write fclass_;
end;
[ROService(__ServiceName)]
TNewService = class(TRORemoteDataModule)
private
public
[ROServiceMethod]
function Echo(a: TMyStruct): TMyStruct;
end;
will be read/written correctly:
{"version":"1.1","result":{"class":"test"}}
Note: this change was included into beta branch only