mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Grid export: implement JSON Lines format. Closes #1930
This commit is contained in:
@ -23,7 +23,8 @@ type
|
|||||||
efJiraTextile,
|
efJiraTextile,
|
||||||
efPHPArray,
|
efPHPArray,
|
||||||
efMarkDown,
|
efMarkDown,
|
||||||
efJSON
|
efJSON,
|
||||||
|
efJSONLines
|
||||||
);
|
);
|
||||||
|
|
||||||
TfrmExportGrid = class(TExtForm)
|
TfrmExportGrid = class(TExtForm)
|
||||||
@ -116,7 +117,8 @@ type
|
|||||||
('jira-textile'),
|
('jira-textile'),
|
||||||
('php'),
|
('php'),
|
||||||
('md'),
|
('md'),
|
||||||
('json')
|
('json'),
|
||||||
|
('jsonl')
|
||||||
);
|
);
|
||||||
const FormatToDescription: Array[TGridExportFormat] of String =
|
const FormatToDescription: Array[TGridExportFormat] of String =
|
||||||
(
|
(
|
||||||
@ -134,7 +136,8 @@ type
|
|||||||
('Jira Textile'),
|
('Jira Textile'),
|
||||||
('PHP Array'),
|
('PHP Array'),
|
||||||
('Markdown Here'),
|
('Markdown Here'),
|
||||||
('JSON')
|
('JSON'),
|
||||||
|
('JSON Lines')
|
||||||
);
|
);
|
||||||
const FormatToImageIndex: Array[TGridExportFormat] of Integer =
|
const FormatToImageIndex: Array[TGridExportFormat] of Integer =
|
||||||
(
|
(
|
||||||
@ -152,7 +155,8 @@ type
|
|||||||
154, // Jira
|
154, // Jira
|
||||||
202, // PHP
|
202, // PHP
|
||||||
199, // Markdown
|
199, // Markdown
|
||||||
200 // JSON
|
200, // JSON
|
||||||
|
200 // JSON Lines
|
||||||
);
|
);
|
||||||
const CopyAsActionPrefix = 'actCopyAs';
|
const CopyAsActionPrefix = 'actCopyAs';
|
||||||
property Grid: TVirtualStringTree read FGrid write FGrid;
|
property Grid: TVirtualStringTree read FGrid write FGrid;
|
||||||
@ -917,6 +921,13 @@ begin
|
|||||||
tmp := CRLF + #9#9 + '{' + CRLF
|
tmp := CRLF + #9#9 + '{' + CRLF
|
||||||
else
|
else
|
||||||
tmp := CRLF + #9#9 + '[' + CRLF
|
tmp := CRLF + #9#9 + '[' + CRLF
|
||||||
|
end;
|
||||||
|
|
||||||
|
efJSONLines: begin
|
||||||
|
if chkIncludeColumnNames.Checked then
|
||||||
|
tmp := '{'
|
||||||
|
else
|
||||||
|
tmp := '[';
|
||||||
end
|
end
|
||||||
|
|
||||||
else tmp := '';
|
else tmp := '';
|
||||||
@ -1051,6 +1062,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
efJSONLines: begin
|
||||||
|
if chkIncludeColumnNames.Checked then
|
||||||
|
tmp := tmp + FormatPhp(Grid.Header.Columns[Col].Text) + ': ';
|
||||||
|
if GridData.IsNull(ResultCol) then
|
||||||
|
tmp := tmp + 'null, '
|
||||||
|
else begin
|
||||||
|
case GridData.DataType(ResultCol).Category of
|
||||||
|
dtcInteger, dtcReal:
|
||||||
|
tmp := tmp + Data;
|
||||||
|
else
|
||||||
|
tmp := tmp + FormatPhp(Data)
|
||||||
|
end;
|
||||||
|
tmp := tmp + ', ';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1086,6 +1113,13 @@ begin
|
|||||||
else
|
else
|
||||||
tmp := tmp + #9#9 + '],';
|
tmp := tmp + #9#9 + '],';
|
||||||
end;
|
end;
|
||||||
|
efJSONLines: begin
|
||||||
|
Delete(tmp, length(tmp)-1,2);
|
||||||
|
if chkIncludeColumnNames.Checked then
|
||||||
|
tmp := tmp + '}' + #10
|
||||||
|
else
|
||||||
|
tmp := tmp + ']' + #10;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
S.WriteString(tmp);
|
S.WriteString(tmp);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user