Skip to content

Commit 7eee130

Browse files
committed
fix: fixing the JSON format
1 parent 9054f9b commit 7eee130

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/renderer/screens/DatabaseScreen/QueryResultViewer/useDataTableContextMenu.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,19 @@ export default function useDataTableContextMenu({
7979
}
8080

8181
function onCopyAsJson() {
82-
window.navigator.clipboard.writeText(
83-
JSON.stringify(
84-
selectedRowsIndex.map((rowIndex) => data[rowIndex].data),
85-
undefined,
86-
2,
82+
const jsonFriendly = selectedRowsIndex.map((rowIndex) =>
83+
Object.entries(data[rowIndex].data).reduce(
84+
(acc, [colName, colValue]) => {
85+
acc[colName] = colValue.toNullableString();
86+
return acc;
87+
},
88+
{} as Record<string, unknown>,
8789
),
8890
);
91+
92+
window.navigator.clipboard.writeText(
93+
JSON.stringify(jsonFriendly, undefined, 2),
94+
);
8995
}
9096

9197
function onCopyAsMarkdown() {

0 commit comments

Comments
 (0)