A valid JSON string.
Optional
reviver: (this: unknown, key: string, value: unknown) => unknownA function that transforms the results. This function is called for each member of
the object. If a member contains nested objects, the nested objects are transformed before the
parent object is. Note that null
values are converted into undefined
values after the
reviver has run.
Converts a JSON string into a value, converting all
null
properties from JSON intoundefined
in the returned JavaScript value/object.WARNING:
null
values will becomeundefined
values after passing through serialize then deserialize. For example,{ a: 1, b: undefined, c: null }
will become{ a: 1, b: undefined, c: undefined }
. If you are passing around user data that needs to retainnull
values, you should wrap them yourself in a string before using this function. Alternatively, you can write your own replacer that will preservenull
in a way that you can recover later.