Skip to content

Commit

Permalink
Move the decoding above the string parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmasuch committed Aug 23, 2023
1 parent 1438cc9 commit df5aec5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions frontend/src/lib/components/widgets/DataFrame/columns/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) =>
Expand Down

0 comments on commit df5aec5

Please sign in to comment.