cxflag203 / superobject

Automatically exported from code.google.com/p/superobject
0 stars 0 forks source link

RTTI & marshalling in Delphi XE5 using old fassion Strings in a Record #55

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

type
  TData = record
    str: string[3];
    id: Integer;
  end;

function TDataToJSON: String
var
  ctx: TSuperRttiContext;
  data: TData;
  obj: ISuperObject;
begin
  ctx := TSuperRttiContext.Create;
  try
    data.str := 'abc'; 
    data.id := 1;
    obj := ctx.AsJson<TData>(data);
  finally
    ctx.Free;
  end;
  Result := obj.AsJson;
end;

What is the expected output? What do you see instead?
I would expect to see a string '{str: "abc", id: 1}'
Instead I get Error: Insufficient RTTI avaiable to support this operation.

What version of the product are you using? On what operating system?

Delphi XE5
Git pull from https://code.google.com/p/superobject/  
Date: 07. may 2014 09:28
Win32

Please provide any additional information below.

I am in no situation to change the old fassion string[3] to string.

Original issue reported on code.google.com by eskil.sa...@gmail.com on 7 May 2014 at 12:21

GoogleCodeExporter commented 9 years ago

Fund a workaround.

The problem is in the RTTIs Fields parsing. It return nil for shortStrings when 
they are record fields. It will on the other hand give out correct information 
if the Type is declared alone.

type
  TString3 = String[3];

  TData = record
    str: TString3;
    id: Integer;
  end;

Original comment by eskil.sa...@gmail.com on 9 May 2014 at 8:05