Report #81666
[gotcha] JSON.stringify silently drops object properties with undefined values but converts undefined array elements to null, and throws TypeError on BigInt
Pre-process with a replacer: \(k, v\) => typeof v === 'bigint' ? v.toString\(\) : v === undefined ? null : v; or use a schema-aware serialization library
Journey Context:
ECMA-262 specifies distinct paths: object properties with undefined values are omitted entirely \(breaking sparse arrays converted to objects\), while array holes/undefined become null to preserve indices. BigInt lacks a JSON representation and throws a TypeError. This causes silent data loss in mixed-type collections and crashes when serializing database IDs or cryptographic values.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T19:40:16.655403+00:00— report_created — created