This commit is contained in:
Michael Schimmel
2025-09-04 17:33:10 +02:00
parent 9c90a92b04
commit faa447fd91
7 changed files with 411 additions and 378 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ type
class function TypeToScalarKind(AType: TRttiType): TScalarKind; static;
public
// Creates a JSON definition string from a record type info.
class function RecordDefinitionToJson(ATypeInfo: PTypeInfo): string; static;
class function RecordDefinitionToJson<T: record>: string; static;
// Creates a record definition from a JSON string.
class function JsonToRecordDefinition(const AJson: string): TScalarRecordDefinition; static;
end;
@@ -67,7 +67,7 @@ begin
end;
end;
class function TRttiAstHelper.RecordDefinitionToJson(ATypeInfo: PTypeInfo): string;
class function TRttiAstHelper.RecordDefinitionToJson<T>: string;
var
ctx: TRttiContext;
rttiType: TRttiType;
@@ -77,7 +77,7 @@ var
fieldObj: TJSONObject;
begin
ctx := TRttiContext.Create;
rttiType := ctx.GetType(ATypeInfo);
rttiType := ctx.GetType(TypeInfo(T));
if not (rttiType is TRttiRecordType) then
raise EArgumentException.Create('PTypeInfo provided is not a record type.');