tough-cookie.fromjson.md

August 1, 2025 ยท View on GitHub

Home > tough-cookie > fromJSON

fromJSON() function

Does the reverse of Cookie.toJSON().

Signature:

declare function fromJSON(str: unknown): Cookie | undefined;

Parameters

Parameter

Type

Description

str

unknown

An unparsed JSON string or a value that has already been parsed as JSON

Returns:

Cookie | undefined

Remarks

Any Date properties (such as .expires, .creation, and .lastAccessed) are parsed via Date.parse, not tough-cookie's parseDate, since ISO timestamps are being handled at this layer.