Skip to content

Commit 434a727

Browse files
committed
fix: DataFrame.toJSON() crashes on BigInt values (TypeError: Do not know how to serialize a BigInt)
JSON.stringify throws on BigInt — added bigIntReplacer (converts to string). The worker HTTP layer already used bigIntReplacer but the DataFrame API didn't.
1 parent 292d482 commit 434a727

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type {
1717
} from "./types.js";
1818
import { NULL_SENTINEL, rowComparator } from "./types.js";
1919
import type { Operator, RowBatch } from "./operators.js";
20-
import { rowPassesFilters } from "./decode.js";
20+
import { rowPassesFilters, bigIntReplacer } from "./decode.js";
2121
import { computePartialAgg, finalizePartialAgg } from "./partial-agg.js";
2222
import { descriptorToCode } from "./descriptor-to-code.js";
2323

@@ -682,7 +682,7 @@ export class DataFrame<T extends Row = Row> {
682682
/** Export collected rows as JSON string. */
683683
async toJSON(opts?: { pretty?: boolean }): Promise<string> {
684684
const result = await this.collect();
685-
return JSON.stringify(result.rows, null, opts?.pretty ? 2 : undefined);
685+
return JSON.stringify(result.rows, bigIntReplacer, opts?.pretty ? 2 : undefined);
686686
}
687687

688688
/** Export collected rows as CSV string. */

0 commit comments

Comments
 (0)