Home > tough-cookie > Cookie > toJSON
For convenience in using JSON.stringify(cookie)
. Returns a plain-old Object that can be JSON-serialized.
Signature:
toJSON(): SerializedCookie;
Returns:
-
Any
Date
properties (such as Cookie.expires, Cookie.creation, and Cookie.lastAccessed) are exported in ISO format (Date.toISOString()
). -
Custom Cookie properties are discarded. In tough-cookie 1.x, since there was no Cookie.toJSON() method explicitly defined, all enumerable properties were captured. If you want a property to be serialized, add the property name to Cookie.serializableProperties.