#1 2013-01-29 11:19:06

p.s.t.
Member
Registered: 2012-12-20
Posts: 9

Rtti

I need to write custom JSON Serializer. In this case I want to use Synopse RTTI instead of native Delphi RTTI. Is it possible to obtain public fields and properties with Synopse RTTI? I can't find any example for obtaining fields information.  For obtaining properties I use following code:

 CP := InternalClassProp(AClass);
    if CP<>nil then begin
      P := @CP^.PropList;
      for i := 0 to CP^.PropCount-1 do
      begin
        LPropertyInfo.PropType := P^.PropType^.Name;
        if P^.Index > 0 then
          LPropertyInfo.PropLength := P^.Index
        else
          LPropertyInfo.PropLength := 0;
        Result.Add(P^.Name, LPropertyInfo);
        P := P^.Next;
      end;
    end;

Offline

#2 2013-01-29 14:17:47

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Rtti

mORMot.pas RTTI is only "classic" RTTI, so it will give you only published properties, not public properties.

You need the extended RTTI information for public properties.

Offline

Board footer

Powered by FluxBB