From df5aec5444a345cdedd7358aa2a4b011d55ff8f5 Mon Sep 17 00:00:00 2001 From: lukasmasuch Date: Wed, 23 Aug 2023 10:23:31 +0200 Subject: [PATCH] Move the decoding above the string parsing --- .../widgets/DataFrame/columns/utils.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/lib/components/widgets/DataFrame/columns/utils.ts b/frontend/src/lib/components/widgets/DataFrame/columns/utils.ts index 3019be42c99f..71246237a26f 100644 --- a/frontend/src/lib/components/widgets/DataFrame/columns/utils.ts +++ b/frontend/src/lib/components/widgets/DataFrame/columns/utils.ts @@ -274,6 +274,14 @@ export function toSafeArray(data: any): any[] { return [data] } + if (data instanceof Uint8Array) { + // Stlite: Uint8Array is used for any list data in fastparquet. + // It stores a json string representation in the Uint8Array. + // We need to convert this to a string first + // to later have it load as json. + data = new TextDecoder("utf-8").decode(data) + } + if (typeof data === "string") { if (data === "") { // Empty string @@ -294,14 +302,6 @@ export function toSafeArray(data: any): any[] { } } - if (data instanceof Uint8Array) { - // Stlite: Uint8Array is used for any list data in fastparquet. - // It stores a json string representation in the Uint8Array. - // We need to convert this to a string first - // to later have it load as json. - data = new TextDecoder("utf-8").decode(data) - } - try { const parsedData = JSON.parse( JSON.stringify(data, (_key, value) =>