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:
{"customer": 1, "messages": "Test Message", "expire": "2017-07-19", "instructions": [{"TextInstructions": "Text1" }, {"TextInstructions": "Text2"}, { "TextInstructions": "Text3"}, {"TextInstructions": "Text4" }]}
I need this:
{"customer": 1, "messages": "Test Message", "expire"
: "2017-07-19", "instructions": ["Text1", "Text2", "Text23", "Text4"] }
Can anyone help me?