A JavaScript value, usually an object or array, to be converted.
Optionalreplacer: (this: unknown, key: string, value: unknown) => unknownA function that transforms the results. Note that all undefined values returned
by the replacer will be further transformed into null in the JSON string.
Optionalspace: string | numberAdds indentation, white space, and line break characters to the return-value JSON
text to make it easier to read. See the space parameter of JSON.stringify for more
details.
Converts a JavaScript value to a JSON string, changing
undefinedproperties in the JavaScript object tonullproperties in the JSON string.WARNING:
nullvalues will becomeundefinedvalues 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 retainnullvalues, you should wrap them yourself in a string before using this function. Alternatively, you can write your own replacer that will preservenullin a way that you can recover later.