Changes on fpjsonrtti to stream TList objects
Original Reporter info from Mantis: Elazar
-
Reporter name: Elazar
Original Reporter info from Mantis: Elazar
- Reporter name: Elazar
Description:
In some cases TJSONStreamer is not able to read all information in some classes I was working, so I made a change to it works with classes with TList properties.
I know about last modification to work with TObjectLists but this is not my case at this very moment.
Another custom modification i made to TJSONStreamer is about an option to put property names in lower case, this may help.
I'm uploading a test project and fpjsonrtti with changes I made, so you will be able to reproduce compiling then
Steps to reproduce:
I have some classes like this:
{ }
TObjItem = class(TObject)
strict private
FID : Integer;
FName : String;
FValue : Double;
published
property ID : Integer read FID write FID;
property Name : String read FName write FName;
property Value : Double read FValue write FValue;
end;
{ }
TCustomList = class(TObject)
private
FApis : TList;
FLastInfo : String;
public
constructor Create; virtual;
destructor Destroy; override;
procedure Add(aItem : TObjItem);
function GetStr : String;
published
property Apis : TList read FApis;
property LastInfo : String read FLastInfo;
end;
And the result json will looks like this:
{"apis":[{"id":1,"name":"Elazar","value":3.4343230000000003E+004},{"id":2,"name":"Name 2","value":3.4341300000000001E+003},{"id":3,"name":"Name 3","value":3.3332100000000000E+003},{"id":4,"name":"Name 4","value":1.1133000000000000E+002},{"id":5,"name":"Name 5","value":3.4223200000000002E+003}],"lastinfo":"Name 5"}
I'm uploading a test project and fpjsonrtti with changes I made, so you will be able to reproduce;
Mantis conversion info:
- Mantis ID: 31513
- Fixed in version: 3.1.1
- Fixed in revision: 35561 (#ea7f7c1d)
- Target version: 3.2.0