Skip to content

@technobuddha > library > JSON > Serialization

Function: replacer()

ts
function replacer(
   this: Record<string, unknown>, 
   key: string, 
   value: unknown): unknown;

Defined in: replacer.ts:13

Used with JSON.stringify to encode a wider range of objects into strings that can later be decoded with reviver

Parameters

ParameterTypeDescription
thisRecord<string, unknown>The raw object being stringified
keystringThe key for the field
valueunknownThe value (may have already been encoded into a string)

Returns

unknown

the encoded value

Remarks

Will encode Date, RegExp and BigInt objects. The numeric values 'Infinity' and 'NaN' are also encoded.