I found a way that I can fix it, but I am not sure, if it is the best way...
type
TRows = array of array of string;
TCols = array of string;
procedure TForm1.AdvGlowButton1Click(Sender: TObject);
var JSON: string;
ClientItem: TJSONValue;
ClientList: TJSONArray;
Rows: TRows;
Cols: TCols;
I, J: Integer;
SQL_Text: string;
Value_String: string;
begin
JSON := Memo_JSstring.Lines.Text;
SetLength(Cols, 6);
SetLength(Rows, Length(Cols),0);
Cols[0] := 'BNumber';
Cols[1] := 'Print_Status';
Cols[2] := 'Ship_Date';
Cols[3] := 'Ship_Time';
Cols[4] := 'TNumber';
Cols[5] := 'VDienstL';
ClientList := TJSONArray.Create;
try
ClientList := TJSONObject.ParseJSONValue(JSON) as TJSONArray;
I := 0;
for ClientItem in ClientList do begin
SetLength(Rows, Length(Cols), Length(Rows[0])+1);
for J := 0 to Length(Cols) -1 do begin
Rows[J,I] := ClientItem.GetValue(Cols[J]);
end;
INC(I);
end;
for I := 0 to Length(Rows[0]) -1 do begin
if I=0 then begin
Value_String := '';
end
else begin
Value_String := Value_String + ', ';
end;
Value_String := Value_String+ '('+
QuotedStr(Rows[0,I])+', '+
QuotedStr(Rows[1,I])+', '+
QuotedStr(Rows[2,I])+', '+
QuotedStr(Rows[3,I])+', '+
QuotedStr(Rows[4,I])+', '+
QuotedStr(Rows[5,I])+') ';
end;
@Hiby_Patrick please use the preformatted text option to format your code, not block quote. This button:
It's very confusing to read your code like that. Your second code seem to leak memory, you don't have to create a TJSONArray in advance just to discard it after a ParseObject is called.