cxflag203 / superobject

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

Problem with deserialization #40

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I found an issue with deserialization. When I try to deserialize json which 
doesn't contain all object's fields or contains null I got Marshalling Error.
Please check the source code in attached file.

Kind Regards
P.S.

Original issue reported on code.google.com by p.stro...@gmail.com on 20 Mar 2013 at 2:31

Attachments:

GoogleCodeExporter commented 9 years ago
in superobject.pas, find this below:

Result := FromJson(f.FieldType.Handle, GetFieldDefault(f, 
obj.AsObject[GetFieldName(f)]), v);
        if Result then

then modify it:

f.SetValue(p, v);
result:=true;

remove the if statement.

Original comment by myiis...@gmail.com on 24 Mar 2013 at 3:03

GoogleCodeExporter commented 9 years ago
I think it should be modified to stay that way

if FromJson(f.FieldType.Handle, GetFieldDefault(f, 
obj.AsObject[GetFieldName(f)]), v) then
  f.SetValue(Value.AsObject, v);

Original comment by fabricio...@gmail.com on 2 Apr 2013 at 11:13

GoogleCodeExporter commented 9 years ago
So, what's the solution or workaround when the JSON has not all the fields of 
the class and the deserealization fails?.

Original comment by pool.l...@gmail.com on 17 Jul 2013 at 9:51