Serializing header value with JSON.stringify doesn't include escape chars

Howdy, good people of the Postman community.

I have this pre-request script where I’m hoping to serialize a header value and store it as a global variable so that it may be used in the same request. Now, I was under the assumption that JSON.stringify included escape characters, but it doesn’t seem like it does since the variable is stored without any backslashes.

Is this intentional? Does Postman remove the backslashes when storing serialized JSON as a variable? Is there any way I can force JSON.stringify to include backslashes or do I have to use some regex magic in this case?

You will be blown away…

pm.variables.set(‘payload’, JSON.stringify(JSON.stringify(payload)));