0
type
TRecordInstructions = record
TextInstructions : RawUTF8;
end;
TArrayInstructions = array of TRecordInstructions;
type
TDoctoVO = class
private
p_customer : Integer;
p_messages : RawUTF8;
p_expire : TDateTime;
p_instructions : TArrayInstructions;
published
property customer : Integer read p_customer write p_customer;
property messages : RawUTF8 read p_messages write p_messages;
property expire : TDateTime read p_expire write p_expire;
property instructions : TArrayInstructions read p_instructions write p_instructions;
constructor Create;
destructor Destroy; override;
end;type
TRecordInstructions = record
TextInstructions : RawUTF8;
end;
TArrayInstructions = array of TRecordInstructions;
type
TDoctoVO = class
private
p_customer : Integer;
p_messages : RawUTF8;
p_expire : TDateTime;
p_instructions : TArrayInstructions;
published
property customer : Integer read p_customer write p_customer;
property messages : RawUTF8 read p_messages write p_messages;
property expire : TDateTime read p_expire write p_expire;
property instructions : TArrayInstructions read p_instructions write p_instructions;
constructor Create;
destructor Destroy; override;
end;`
.
.
TDoctoVO }
constructor TDoctoVO.Create;
begin
SetLength(p_instructions, 4);
end;
.
.
.
destructor TDoctoVO.Destroy;
begin
FreeAndNil(p_instructions);
inherited;
end;
Estou tentando serializar assim:
var
DoctoVO : TDoctoVO;
DoctoVO := TDoctoVO.Create;
begin
DoctoVO.customer := 1;
DoctoVO.messages := 'Test Mesagens';
DoctoVO.expire := StrToDate('2017-07-19');
DoctoVO.instructions[0].TextInstructions := 'Text1';
DoctoVO.instructions[1].TextInstructions := 'Text2';
DoctoVO.instructions[2].TextInstructions := 'Text3';
DoctoVO.instructions[3].TextInstructions := 'Text4';
Memo.Lines.Text := JSONReformat(ObjectToJson(DoctoVO));
end;
Answer:
{ "Search": 1, "messages": "Test Merges", "expire": "2017-07-19", "Instructions": [ "Textinstructions": "Text1" }, ː "Textinstructions": "Text2" }, { "Textinstructions": "Text3" }, ː "Textinstructions": "Text4" } ] }
I need it like this:
{ "Customer": 1, "messages": "Test Mergers", "expire"
: "2017-07-19", "Instructions" ["Text1","Text2","Text23","Text4"] }
Can someone help me?