Skip to main content
Version: 0.96.0

Function: bigIntReviver()

bigIntReviver(_key: string, value: unknown): unknown

Defined in: utils.ts:258

JSON reviver function that converts numeric strings back to BigInt.

Parameters

ParameterTypeDescription
_keystringProperty key (unused).
valueunknownValue to transform.

Returns

unknown

BigInt if numeric string, otherwise unchanged value.

Example

TypeScript
import { bigIntReviver } from '@chainlink/ccip-sdk'

const json = '{"amount":"1000000000000000000"}'
const data = JSON.parse(json, bigIntReviver)
console.log(typeof data.amount) // 'bigint'

See

bigIntReplacer - Stringify BigInt values