stringify

Stringify a JSON object and convert all bigint values to string

If you are getting this error: "Exception: Do not know how to serialize a BigInt", you probably can use this function to parse the data. Because bigint is not an accepted value of the JSON format.

Example

import { stringify } from "thirdweb/utils";
const obj = { tokenId: 0n };
const str = stringify(obj); // "{"tokenId":"0"}"
function stringify(
value: any,
replacer?: null | ((this: any, key: string, value: any) => any),
space?: string | number,
): string;

Parameters

Type

let value: any;

Type

let replacer: null | ((this: any, key: string, value: any) => any);

Type

let space: string | number;

Returns

let returnType: string;

An object with all bigint values converted to string