4 ms·
All the data comes from a JSON API and thus doesn't contain Date objects to begin with.
by RedShift1 4y ago
All the data comes from a JSON API and thus doesn't contain Date objects to begin with.
- deleted 4y ago[deleted]
- nishs 4y agoMakes sense for the most part with these constraints then. I missed the "primitive types" portion in the original comment. The following isn't applicable for pure JSON responses, but is applicable for primitive types: An additional condition for bigint is necessary, which is a primitive type. Otherwise JSON.stringify throws: >>> const x = { i: BigInt("0x1fffffffffffff") } undefined >>> typeof x.i "bigint" >>> const b = JSON.parse(JSON.stringify(x)) Exception: TypeError: JSON.stringify cannot serialize BigInt. >>> ... and for the symbol primitive, which JSON.stringifys to undefined, and thus can't be JSON.parsed.