• Recursively convert BigInt values to string so the result is safe for JSON.stringify().

    Useful in Next.js API Routes, Express handlers, or anywhere you need to serialize gateway / x402 objects that contain BigInt fields like pricePerCall, maxBudget, or amountCharged.

    Parameters

    • obj: unknown

      Any value (object, array, primitive, BigInt).

    Returns unknown

    A deep clone with every BigInt replaced by its string representation.

    1.2.2

    import { toJsonSafe } from '@oobe-protocol-labs/synapse-client-sdk/utils';

    return NextResponse.json(toJsonSafe({ budget: 100_000n, data }));