joaorobertoct2 / x-superobject

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

Problems with reconverting ObjectList #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Converting an ObjectList into JSON
2.Reconverting the JSON into the ObjectList
3.

What is the expected output? What do you see instead?
I expect a filled ObjectList, instead I get an exception during reading the JSON
I think the problem is the generated JSON-String. If I fill the list with a 
manual written JSON-String
{MeineList: [{Name:"Hallo", Size: 1.72}, {Name:"Hallo", Size: 1.72} ]} it works 
without any problem

If I convert an existing ObjectList into JSON I get following JSON-String

{"MeineList":{"OwnsObjects":false,"Capacity":2,"Count":2,"List":[{"Name":"Hallo"
,"Size":1.72},{"Name":"Hallo","Size":1.72}]}}

During reconverting the JSON into the object I get an EInvalidCast exception

I attached demo project with my code.

What version of the product are you using? On what operating system?
Win7, Delphi XE5, r86 

THANKS for your help!

Original issue reported on code.google.com by svenbemm...@gmail.com on 12 Dec 2014 at 8:49

Attachments:

GoogleCodeExporter commented 9 years ago
Yes, I faced to this problem too.
Please take your attention to it.

Original comment by vladimir...@gmail.com on 5 Mar 2015 at 4:12

GoogleCodeExporter commented 9 years ago
I changed one of overloaded faunctions to get the correct JSON for TObjectList
We need to remember, that deserializing will not works for inherited classes 
i.e.
TNewClass = class(TObjectList<TSomeClass>)
end;

class function TSerializeParse.IsGenerics(Cls: TClass): Boolean;
var
  Info: TGenericsInfo;
  Ctx: TRttiContext;
  Typ: TRttiType;
begin
  Ctx := TRttiContext.Create;
  try
    Typ := Ctx.GetType(Cls);
    result:=IsGenerics(Typ);
  finally
    Ctx.Free;
  end;
end;

Original comment by vladimir...@gmail.com on 5 Mar 2015 at 6:50

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r89.

Original comment by onryld...@gmail.com on 10 Mar 2015 at 10:20