From ebdc89f97c3e2f851833fe95dcf626b70cd3e2e8 Mon Sep 17 00:00:00 2001 From: Anton Kastritskiy Date: Tue, 23 Jul 2024 06:42:00 -0700 Subject: [PATCH] copy json with bigint Summary: Addresses support post https://fb.workplace.com/groups/flippersupport/posts/1879751489172167 Reviewed By: LukeDefeo Differential Revision: D60112240 fbshipit-source-id: 916a3d296a4d24e398bb42fc36a7153226d77eb6 --- .../ui/data-table/PowerSearchTableContextMenu.tsx | 13 +++++++++++-- .../src/ui/data-table/TableContextMenu.tsx | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/desktop/flipper-plugin/src/ui/data-table/PowerSearchTableContextMenu.tsx b/desktop/flipper-plugin/src/ui/data-table/PowerSearchTableContextMenu.tsx index 86e5f62a251..de67433ebfd 100644 --- a/desktop/flipper-plugin/src/ui/data-table/PowerSearchTableContextMenu.tsx +++ b/desktop/flipper-plugin/src/ui/data-table/PowerSearchTableContextMenu.tsx @@ -201,6 +201,15 @@ function defaultOnCopyRows( .join('\n')}`; } -function rowsToJson(items: T[]) { - return JSON.stringify(items.length > 1 ? items : items[0], null, 2); +function rowsToJson(items: any[]) { + return JSON.stringify( + items.length > 1 ? items : items[0], + function (_key, value) { + if (typeof value === 'bigint') { + return `${value.toString()}n`; + } + return value; + }, + 2, + ); } diff --git a/desktop/flipper-plugin/src/ui/data-table/TableContextMenu.tsx b/desktop/flipper-plugin/src/ui/data-table/TableContextMenu.tsx index 43db7d1a4f9..bdb02d6980d 100644 --- a/desktop/flipper-plugin/src/ui/data-table/TableContextMenu.tsx +++ b/desktop/flipper-plugin/src/ui/data-table/TableContextMenu.tsx @@ -293,6 +293,15 @@ function defaultOnCopyRows( .join('\n')}`; } -function rowsToJson(items: T[]) { - return JSON.stringify(items.length > 1 ? items : items[0], null, 2); +function rowsToJson(items: any[]) { + return JSON.stringify( + items.length > 1 ? items : items[0], + function (_key, value) { + if (typeof value === 'bigint') { + return `${value.toString()}n`; + } + return value; + }, + 2, + ); }